Part Number Hot Search : 
IC18F MAX5116 BC847C BUP410 X24F064 UPD7514 74LS13 1N6126AS
Product Description
Full Text Search
 

To Download SM39R16A3 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 1 - product list ......................................................................................................................................................................... 3 description .......................................................................................................................................................................... 3 ordering information ........................................................................................................................................................... 3 features .............................................................................................................................................................................. 3 pin configuration ................................................................................................................................................................ 4 block diagram ..................................................................................................................................................................... 6 pin description .................................................................................................................................................................... 7 special function register (sfr ) ........................................................................................................................................ 8 function description ......................................................................................................................................................... 12 1. general features ..................................................................................................................................................... 12 1.1 embedded flash ............................................................................................................................................. 12 1.2 io pads ............................................................................................................................................................ 12 1.3 instruction timing selection ............................................................................................................................. 12 1.4 the clock out selection .................................................................................................................................. 1 3 1.5 reset ............................................................................................................................................................. 13 1.5.1 hardware reset function .......................................................................................................................... 13 1.5.2 software reset function ........................................................................................................................... 13 1.5.3 res et status ................................................................................................................................................ 14 1.5.4 time access key register (takey) ............................................................................................................. 14 1.5.5 software reset register (swres) .............................................................................................................. 14 1.5.6 example of software reset ........................................................................................................................... 15 1.6 clocks .............................................................................................................................................................. 15 2. instruction set .......................................................................................................................................................... 16 3. memory structure ..................................................................................................................................................... 20 3.1 program memory ............................................................................................................................................. 20 3.2 data memory ................................................................................................................................................... 21 3.3 data memory - lower 128 byte (00h to 7fh) ................................................................................................... 21 3.4 data memory - higher 128 byte (80h to ffh) .................................................................................................. 21 3.5 data memory - expanded 256 bytes ($00 $ff) ......................................................................................... 21 4. cpu engine ............................................................................................................................................................. 22 4.1 accumulator ..................................................................................................................................................... 22 4.2 b register ........................................................................................................................................................ 22 4.3 program status word ...................................................................................................................................... 23 4.4 stack pointer ................................................................................................................................................... 23 4.5 data pointer ..................................................................................................................................................... 23 4.6 data pointer 1 .................................................................................................................................................. 24 4.7 clock control register ....................................................................................................................................... 24 4.8 interface control register .................................................................................................................................. 25 5. gpio ........................................................................................................................................................................ 26 5.1 sfr setting method ........................................................................................................................................ 26 5.2 software of writer setting method .................................................................................................................. 27 6. timer 0 and timer 1 ................................................................................................................................................. 28 6.1 timer/ counter mode control register (tmod) ................................................................................................. 28 6.2 timer/counter control register (tcon) ............................................................................................................ 29 6.3 enhance interrupt trigger sfr( enhit ) .......................................................................................................... 30 6.4 peripheral frequency control register ............................................................................................................. 30 6.5 mode 0 (13 - bit counter/timer) ........................................................................................................................ 31 6.6 mode 1 (16 - bit counter/timer) ........................................................................................................................ 32 6.7 mode 2 (8 - bit auto - reload counter/timer) ....................................................................................................... 32 6.8 mode 3 (timer 0 acts as two independent 8 bit timers / counters) ................................................................ 33 7. timer 2 and capture compare unit ......................................................................................................................... 34 7.1 timer 2 function ............................................................................................................................................... 37 7.1.1 timer mode ................................................................................................................................................. 37 7.1.2 event counter mode .................................................................................................................................... 37 7.1.3 gated timer mode ....................................................................................................................................... 38 7.1.4 reload of timer 2 ........................................................................................................................................ 38
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 2 - 7.2 compare function ............................................................................................................................................ 38 7.2.1 compare mode 0 ........................................................................................................................................ 38 7.2.2 compare mode 1 ........................................................................................................................................ 39 7.3 capture function .............................................................................................................................................. 39 7.3.1 captur e mode 0 (by hardware) .................................................................................................................. 40 7.3.2 capture mode 1(by software) ..................................................................................................................... 40 8. serial interface ......................................................................................................................................................... 41 8.1 serial interface ................................................................................................................................................. 42 8.1.1 mode 0 ........................................................................................................................................................ 42 8.1.2 mode 1 ........................................................................................................................................................ 42 8.1.3 mode 2 ........................................................................................................................................................ 43 8.1.4 mode 3 ........................................................................................................................................................ 43 8.2 multiprocessor communication of serial interface .......................................................................................... 43 8.3 peripheral frequency control register ............................................................................................................. 44 8.4 baud rate generator ........................................................................................................................................ 44 8.4.1 serial inter face modes 1 and 3 ................................................................................................................... 44 9. watchdog timer ........................................................................................................................................................ 46 10. interrupt ................................................................................................................................................................ 50 10.1 priority level structure ...................................................................................................................................... 53 11. power management unit ..................................................................................................................................... 55 11.1 idle mode ......................................................................................................................................................... 55 11.2 stop mode ....................................................................................................................................................... 55 12. pulse width modulation (pwm) ........................................................................................................................... 56 13. iic function ........................................................................................................................................................... 59 14. spi function - serial peripheral interface ........................................................................................................... 64 15. kbi ? keyboard interface ..................................................................................................................................... 69 16. lvi & lvr ? low volt age interrupt and low voltage reset ................................................................................ 72 17. 10- bit analog - to - digital converter (adc) ............................................................................................................ 73 18. in - system programming (internal isp) ................................................................................................................ 77 18.1 isp service program ........................................................................................................................................ 77 18.2 lock bit (n) ...................................................................................................................................................... 77 18.3 program the isp service program .................................................................................................................. 78 18.4 initiate isp service program ........................................................................................................................... 78 18.5 isp register ? takey, ifcon, ispfah, ispfal, ispfd and isp fc ............................................................. 79 19. comparator .......................................................................................................................................................... 82 operating conditions ........................................................................................................................................................ 85 dc characteristi cs ............................................................................................................................................................ 85 adc characteristics ......................................................................................................................................................... 87 comparator characteristics .............................................................................................................................................. 87 lvi& lvr characteristics .................................................................................................................................................. 87
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 3 - product list sm39 r16a3 u20, sm39 r16a3 u16, sm39 r16a3 u14, sm 39r 16 a3u1 0 , description the sm39 r16a3 is a 1t (one machine cycle per clock) single - chip 8 - bit microcontroller. it has 16kb embedded flash f or program, and executes all asm51 instructions fully compatible with mcs - 51. sm39 r16a3 cont ains 512b on- chip ram, up to 18 gpios (20l package), various serial interfaces and many peripheral functions as described below. it can be programmed via writers. its on - chip ice is convenient for users in verification during development stage. the high performance of sm39 r16a3 can achieve complicated manipulation within short time. about one third of the instructions are pure 1t, and the average speed is 8 times of traditional 8051, the fastest one among all the 1t 51 - series.its excellent emi and esd characteristics are advantageous for many different applications. ordering information sm39 r16a3 ihhkl yww i: process identifier { u = 1.8v ~ 5.5v} hh: pin count k: package type postfix {as table below } l:pb free identifier {no text is non - pb free ?p? is pb free} y : year ww : week postfix package n pdip (300 mil) s sop (300 mil) o sop ( 15 0 mil) g ssop (150 mil) m m sop (1 18 mil) features ? operating voltage: 1. 8 v ~ 5.5v ? high speed architecture of 1 clock/machine cycle runs up to 25mhz. ? 1~8t can be switched on the fly. ? instruction - set compatible with mcs - 51. ? 22.1184mhz internal rc oscillator, with programmable clock divider ? 16kb on - chip program memory. ? 512b ram a s standard 8052, ? dual 16 - bit data pointers (dptr0 & dptr1). ? one serial peripheral interfaces in full duplex mode. ? additional baud rate generator ? three 16 - b it timer/counters. (timer 0,1,2 ? 12 ~ 18 gpios( 14l ~ 20l package) ? external interrupt 0,1 with four priority levels ? programmable watchdog timer. ? one iic interface. (master/slave mode) ? one spi interface (master/slave mode) ? 4 - channel pwm ? 4 - channel 16 - bit pca for compare(pwm) / capture / rel oad functions ? 7 - channel 10 - bit analog - to - digital converter (adc) and 1- channel adc0 connect to internal reference voltage ? cmp x1 set (2 devices) ? isp/iap/icp functions. ? isp service program space configurable in n*128 byte (n=0 to 8) size. ? eeprom function. ? on - chip in - circuit emulator (ice) functions with on - chip debugger (ocd). ? keyboard interface (kbi) for four more interrupts. ? lvi/lvr (lvr deglitch 500ns) ? io pad esd over 4kv ? enhance user code protection. ? power management unit for idle and power down modes.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 4 - pin configuration 20 pin pdip/sop/ssop 1 2 3 4 5 6 7 8 9 10 20 19 18 17 16 15 14 13 12 11 SM39R16A3 yww (20 pin top view) cmp1out/spiclk/kbi0/p0.0 pwm1/mosi/cc2/p1.7 pwm0/miso/cc1/p1.6 rst/p1.5 vss osc_in/xtal1/p3.1 clkout/xtal2/p3.0 ss/int1/p1.4 ocisda/iicsda/int0/p1.3 ociscl/iicscl/t0/p1.2 p0.1/kbi1/adc1/cmp1nin p0.2/kbi2/adc2/cmp1pin p0.3/kbi3/t2/adc3/cmp0nin p0.4/adc4/cmp0pin p0.5/adc5/cc0/pwm2 vdd p0.6/adc6/cmp0out p0.7/t1/adc7/cc3/pwm3 p1.0/txd p1.1/rxd/t2ex 16 pin sop 1 2 3 4 5 6 7 8 16 15 14 13 12 11 10 9 SM39R16A3 yww (16 pin top view) pwm0/miso/cc1/p1.6 rst/p1.5 vss osc_in/xtal1/p3.1 clkout/xtal2/p3.0 ss/int1/p1.4 ocisda/iicsda/int0/p1.3 ociscl/iicscl/t0/p1.2 p0.3/kbi3/t2/adc3/cmp0nin p0.4/adc4/cmp0pin p0.5/adc5/cc0/pwm2 vdd p0.6/adc6/cmp0out p0.7/t1/adc7/cc3/pwm3 p1.0/txd p1.1/rxd/t2ex
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 5 - 14 pin sop 1 2 3 4 5 6 7 14 13 12 11 10 9 8 SM39R16A3 yww (14 pin top view) pwm0/miso/cc1/p1.6 rst/p1.5 vss osc_in/xtal1/p3.1 clkout/xtal2/p3.0 ocisda/iicsda/int0/p1.3 p1.2/iicscl/t0/ociscl vdd p1.0/txd p1.1/rxd/t2ex pwm1/mosi/cc2/p1.7 p0.0/kbi0/spiclk/cmp1out p0.1/kbi1/adc1/cmp1nin p0.2/kbi2/adc2/cmp1pin 1 0 pin m sop 1 2 3 4 5 10 9 8 7 6 (10 pin top view) pwm0/miso/cc1/p1.6 rst/p1.5 vss ocisda/iicsda/int0/p1.3 ociscl/t0/iicscl/p1.2 vdd p1.0/txd p1.1/rxd/t2ex p0.3/kbi3/t2/adc3/cmp0nin p0.7/t1/adc7/cc3/pwm3 r08a3 xxxxx notes (1) the pin reset/p1.5 factory default is gpio ( p1.5), user must keep this pin at low during power - up. user can configure it to reset by a flash programmer. (2) t o avoid accidentally entering isp - mode(refer to section 18.4), care must be taken not asserting pulse signal at rxd p1.1 during power - up while p1. 6 are set to high. (3) to apply icp function, osi_sda/p1.3 and oci_scl/p1.2 must be set to bi - direction mode if they are configured as gpio in system. .
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 6 - block diagram uart cmp 0 cmp 1 flash 16 k bytes sram 512 bytes interrupt timer 0 / 1 timer 2 & ccu watchdog ice icp port 0 port 1 port 3 port 0 port 1 port 3 t 0 t 1 cc 0 ~ cc 3 t 2 t 2 ex iic _ scl pwm 0 pwm 1 rxd txd cmp 0 nin / cm 1 nin cmp 0 out / cm p 1 out interface control xtal 1 xtal 2 adc 1 adc 2 adc 3 iic _ sda spi spi _ miso spi _ mosi spi _ clk spi _ ss adc 4 adc 5 adc 6 adc 7 cpu pwm adc iic oci _ scl ( share with iic ) oci _ sda ( share with iic ) max 810 reset cmp 0 pin / cmp 1 pin pwm 2 pwm 3
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 7 - pin description 20l 16l 14l 1 0 l symbol i/o description 1 - 14 - p0.0/kbi0/ spiclk/adc0/ cmp1out i/o bit 0 of port 0 & kbi interrupt 0 & spi interface clock pin & cmp1 output 2 - 1 - p1.7/cc2/mosi/pwm1 i/o bit 7 of port 1 & timer 2 compare/capture channel 2 & spi interface serial data master output or slave input p in & pwm channel 1 3 1 2 1 p1.6/cc1/miso/pwm0 i/o bit 6 of port 1 & timer 2 compare/capture channel 1 & spi interface serial data master input or slave output pin & pwm channel 0 4 2 3 2 p1.5/rst i/o bit 5 of port 1 & reset pin(default) 5 3 4 3 vss i po wer supply 6 4 5 - p3.1/xtal1/osc_in i/o bit 1 of port 3 & crystal input(default) & oscillator input 7 5 6 - p3.0/xtal2/clkout i/o bit 0 of port 3 & crystal output(default) & clock output 8 6 - - p1.4/int1/ss i/o bit 4 of port 1 & external interrupt 1 & spi interface slave select pin 9 7 7 4 p1.3/int0/ iicsda/ocisda i/o bit 3 of port 1 & external interrupt 0 & iic sda pin & on - chip instrumentation command and data i/o pin synchronous to oci_scl in ice and icp functions 10 8 8 5 p1.2/t0/iicscl/ ociscl i/o bit 2 of port 1 & timer 0 external input & iic scl pin & on - chip instrumentation clock i/o pin of ice and icp functions 11 9 9 6 p1.1/rxd/t2ex i/o bit 1 of port 1 & serial interface channel 0 receive/transmit data & timer 2 capture trigger 12 10 10 7 p1.0/txd i/o bit 0 of port 1 & serial interface channel 0 transmit data or receive clock in mode 0 13 11 - 9 p0.7/t1/adc7/ cc3/pwm3 i/o bit 7 of port 0 & timer 1 external input & adc input channel 7& timer 2 compare/capture cha nnel 3& pwm channel 3 14 12 - - p0.6/adc6/cmp0out i/o bit 6 of port 0 & adc input channel 6 & cmp0 output 15 13 11 8 vdd i power supply 16 14 - - p0.5/adc5/cc0/pwm2 i/o bit 5 of port 0 & adc input channel 5 & timer 2 compare/capture channel 0& pwm channel 2 17 15 - - p0.4/adc4/ cmp0pin i/o bit 4 of port 0 & adc input channel 4 & cmp0 positive input 18 16 - 10 p0.3/kbi3/t2/ adc3/cmp0nin i/o bit 3 of port 0 & kbi interrupt 3 & timer 2 external input clock & adc input channel 3 & cmp0 negative input 19 - 12 - p0.2/kbi2/adc2/ cmp1 pin i/o bit 2 of port 0 & kbi interrupt 2 & adc input channel 2 & cmp1 positive input 20 - 13 - p0.1/kbi1/adc1/ cmp1nin i/o bit 1 of port 0 & kbi interrupt 1 & adc input channel 1 & cmp1 negative input
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 8 - special function register (sfr ) a map of the speci al function registers is shown as below hex \ bin x000 x001 x010 x011 x100 x101 x110 x111 bin/hex f8 iics iicctl iica1 iica2 iicrwd iicebt cmp0con cmp1con ff f0 b spic1 spic2 spitxd spirxd spis oppin takey f7 e8 ef e0 acc ispfah ispfal ispfd ispfc lvc swres e7 d8 pfcon p3m0 p3m1 df d0 psw ccen2 p0m0 p0m1 p1m0 p1m1 d7 c8 t2con cccon crcl crch tl2 th2 pwmmdh pwmmdl cf c0 ircon ccen ccl1 cch1 ccl2 cch2 ccl3 cch3 c7 b8 ien1 ip1 srelh pwmd0 h pwmd0l pwmd1h pwmd1l bf b0 p3 pwmd2 h pwmd2l pwmd3 h pwmd3l pwmc wdtc wdtk b7 a8 ien 0 ip0 srell adcc1 adcc2 adcdh adcdl adccs af a0 rsts a7 98 scon sbuf ien2 9f 90 p1 aux kbls kbe kbf kbd ircon2 97 88 tcon tmod tl0 tl1 th0 th1 ckcon ifcon 8f 80 p0 sp dpl dph dpl1 dph1 pcon 87 hex \ bin x000 x001 x010 x011 x100 x101 x110 x111 bin/hex note: special function registers reset values and description for sm39 r16a3 register location reset value description system sp 81h 07h stack pointer acc e0h 00h accumulator psw d0h 00h program status word b f0h 00h b register dpl 82h 00h data pointer 0 low byte dph 83h 00h data pointer 0 high byte dpl1 84h 00h data pointer 1 low byte dph1 85h 00h data pointer 1 high byte aux 91h 00h auxiliary register pcon 87h 00h power control ckcon 8eh 10h clock control register interrupt & p riority ircon c0h 00h interrupt request control register ircon2 97h 00h interrupt request control register 2
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 9 - register location reset value description ien0 a8h 00h interrupt enable register 0 ien1 b8h 00h interrupt enable register 1 ien2 9ah 00h interrupt enable register 2 ip0 a9h 00h interr upt priority register 0 ip1 b9h 00h interrupt priority register 1 kbi kbls 93h 00h keyboard level selector register kbe 94h 00h keyboard input enable register kbf 95h 00h keyboard interrupt flag register kbd 96h 00h keyboard interface de - bounce contr ol register uart pcon 87h 00h power control aux 91h 00h auxiliary register scon 98h 00h serial port, control register sbuf 99h 00h serial port, data buffer srell aah 00h serial port, reload register, low byte srelh bah 00h serial port, reload regist er, high byte pfcon d9h 00h peripheral frequency control register adc adcc1 abh 00h adc control 1 register adcc2 ach 00h adc control 2 register adcdh adh 00h adc data high byte adcdl aeh 00h adc data low byte adccs afh 00h adc clock select wdt rst s a1h 00h reset status register wdtc b6h 04h watchdog timer control register wdtk b7h 00h watchdog timer refresh key. takey f7h 00h time access key register pwm pwmc b5h 00h pwm control register pwmd0h bch 00h pwm channel 0 data high byte pwmd0l bdh 00h pwm channel 0 data low byte pwmd1h beh 00h pwm channel 1 data high byte pwmd1l bfh 00h pwm channel 1 data low byte pwmd2h b1h 00h pwm channel 2 data high byte pwmd2l b2h 00h pwm channel 2 data low byte pwmd3h b3h 00h pwm channel 3 data high byte pwmd3l b4h 00h pwm channel 3 data low byte pwmmdh ceh 00h pwm max data register, high byte. pwmmdl cfh ffh pwm max data register, low byte.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 10 - register location reset value description timer0/timer1 tcon 88h 00h timer/counter control tmod 89h 00h timer mode control tl0 8ah 00h timer 0, low byt e tl1 8bh 00h timer 1, low byte th0 8ch 00h timer 0, high byte th1 8dh 00h timer 1, high byte pfcon d9h 00h peripheral frequency control register pca(timer2) ccen c1h 00h compare/capture enable register ccl1 c2h 00h compare/capture register 1, low b yte cch1 c3h 00h compare/capture register 1, high byte ccl2 c4h 00h compare/capture register 2, low byte cch2 c5h 00h compare/capture register 2, high byte ccl3 c6h 00h compare/capture register 3, low byte cch3 c7h 00h compare/capture register 3, high byte t2con c8h 00h timer 2 control cccon c9h 00h compare/capture control crcl cah 00h compare/reload/capture register, low byte crch cbh 00h compare/reload/capture register, high byte tl2 cch 00h timer 2, low byte th2 cdh 00h timer 2, high byte cce n2 d1h 00h compare/capture enable 2 register gpio p0 80h ffh port 0 p1 90h ffh port 1 p3 b0h ffh port 3 p0m0 d2h 00h port 0 output mode 0 p0m1 d3h 00h port 0 output mode 1 p1m0 d4h 00h port 1 output mode 0 p1m1 d5h 00h port 1 output mode 1 p3m0 da h 00h port 3 output mode 0 p3m1 dbh 00h port 3 output mode 1 isp/iap/eeprom ifcon 8fh 00h interface control register ispfah e1h ffh isp flash address - high register ispfal e2h ffh isp flash address - low register ispfd e3h ffh isp flash data register i spfc e4h 00h isp flash control register takey f7h 00h time access key register lvi/lvr/softreset
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 11 - register location reset value description rsts a1h 00h reset status register lvc e6h 20h low voltage control register swres e7h 00h software reset register takey f7h 00h time access key register spi aux 91h 00h auxiliary register spic1 f1h 08h spi control register 1 spic2 f2h 00h spi control register 2 spitxd f3h 00h spi transmit data buffer spirxd f4h 00h spi receive data buffer spis f5h 40h spi status register iic aux 91h 00h auxiliary register iics f8h 00h iic status register iicctl f9h 04h iic control register iica1 fah a0h iic channel 1 address 1 register iica2 fbh 60h iic channel 1 address 2 register iicrwd fch 00h iic channel 1 read / write data buffer iicebt fdh 00h iic enabl e bus transaction register opa oppin f6h 00h comparator pin select register cmp0con feh 00h comparator 0 control register cmp1con ffh 00h comparator 1 control register
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 12 - function description 1. general features sm39 r16a3 is an 8 - bit micro - controller. a ll of its functions and the detailed meanings of sfr will be given in the following sections. 1.1 embedded flas h the program can be loaded into the embedded 16kb flash memory via its writer or in - system programming (isp). the high - quality flash suitable for re - programming and data recording as eeprom. 1.2 io pads the sm39 r16a3 has three i/o ports: port 0, port 1, port 2 and port 3. ports 0, 1, 2 are 8 - bit ports and port 3 is a 2 - bit port. these are: quasi - bidirectional (standard 8051 port outputs), push - pull, op en drain, and input - only. as description in section 5. all the pads for p0 , p1 , p2 and p3 are with slew rate to reduce emi. the io pads can withstand 4kv esd in human body mode guaranteeing the sm39 r16a3 is quality in high electro - static environments. the reset pin can define as general i/o p1.5 when user use internal reset. the xtal2 and xtal1 can define as p3.0 and p3.1 by writer or isp , when user use internal osc as system clock ; when user use external osc as system clock and input into xtal1 , only xtal 2 can be defined as p3.0. 1.3 instruction timing selection the conventional 52 - series mcus are 12t, i.e., 12 oscillator clocks per machine cycle. sm39 r16a3 is a 1t to 8t mcu, i.e., its machine cycle is one - clock to eight - clock. in the other words, it can ex ecute one instruction within one clock to only eight clocks. mnemonic : ckcon address : 8eh 7 6 5 4 3 2 1 0 reset - its[2:0] - - clkout[1:0] 10h its: instruction timing select. its [2:0] instruction timing 000 1t mode 001 2t mode (default) 010 3t mod e 011 4t mode 100 5t mode 101 6t mode 110 7t mode 111 8t mode the default is in 2t mode, and it can be changed to another instruction timing mode if ckcon [6:4] (at address 8eh) is change any time. not every instruction can be executed with one mac hine cycle. the exact machine cycle number for all the instructions are given in the next section.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 13 - 1.4 the clock out selection the sm39 r16a3 can generator a clock out signal at p3.0 when user use oscillator (xtal1 as clock input) or internal osc as system clock. the ckcon [1:0] (at address 8eh) can change any time. clkout: clock output select. ckcon [1:0] mode. 00 gpio(default) 01 fosc 10 fosc/2 11 fosc/4 1.5 rese t 1.5.1 hardware reset function sm39 r16a3 provides internal reset circuit inside , the internal reset time can set by writer or isp. internal reset time 25ms (default) 200ms 100ms 50ms 16ms 8ms 4ms 1.5.2 software reset function sm39 r16a3 provides one software reset mechanism to reset whole chip. to perform a software reset, the firmware must write three specific values 55h, aah and 5ah sequentially to the takey register to enable the software reset register (swres) write attribute. a fter swres register obtain the write authority, the firmware can write ffh to the swres register. the hardware will decode a reset signal that ?or? with the other hardware reset. the swres register is self - reset at the end of the software reset procedure. mnemonic description addr ess bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst software reset function rsts reset status register a1h - - - pdrf wdtf swrf lvrf porf 00h takey time access key register f7h takey [7:0] 00h swres software reset register e7h swres [7:0] 00h
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 14 - 1.5.3 reset status mnemonic : rsts address : a1h 7 6 5 4 3 2 1 0 reset - - - pdrf wdtf swrf lvrf porf 00h pdrf: pad reset flag. when mcu is reset by reset pad, pdrf flag will be set to one by hardware. this flag clear by software. wdt f: watchdog timer reset flag. when mcu is reset by watchdog, wdtf flag will be set to one by hardware. this flag clear by software. swrf: software reset flag. when mcu is reset by software, swrf flag will be set to one by hardware. this flag clear by soft ware. lvrf: low voltage reset flag. when mcu is reset by lvr, lvrf flag will be set to one by hardware. this flag clear by software. porf: power on reset flag. when mcu is reset by por, porf flag will be set to one by hardware. this flag clear by softwar e. 1.5.4 time access key register (takey) mnemonic : takey address : f7h 7 6 5 4 3 2 1 0 reset takey [7:0] 00h software reset register (swres) is read - only by default; software must write three specific values 55h, aah and 5ah sequentially to the takey regist er to enable the swres register write attribute. that is: mov takey, #55h mov takey, #0aah mov takey, #5ah 1.5.5 software reset register (swres) mnemonic : swres address : e7h 7 6 5 4 3 2 1 0 reset swres [7:0] 00h swres[7:0]: software reset register bit. the se 8 - bit is self - reset at the end of the reset procedure. swres [7:0] = ffh, software reset. swres [7:0] = 00h ~ feh, mcu no action.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 15 - 1.5.6 example of software reset mov takey, #55h mov takey, #0aah mov takey, #5ah ; enable swres write attribute mov swres, #0f fh ; software reset mcu 1.6 clocks the default clock is the 22.1184mhz internal osc. this clock is used during the initialization stage. the major work of the initialization stage is to determine the clock source used in normal operation. the internal clock sources are from the internal osc with difference frequ ency division as given in table 1 - 1 the clock source can set by writer or icp. . table 1 - 1 : selection of clock source clock source external crystal (use xtal1 and xtal2 pins ) external crystal (only use xtal1, the xtal2 define as i/o) 22.11 84mhz from internal osc 11 . 0592 mhz from internal osc 5 . 5296 mhz from internal osc 2.7648 mhz from internal osc 1.3824 mhz from internal osc there may be having a little variance in the frequency from the internal osc. th e max variance as giving in table 1 - 2 table 1 - 2 : temperature with variance temperature max variance 25 2 %
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 16 - 2. instruction set all sm39 r16a3 instructions are binary code compatible and perform the same functions as they do with the industry standard 8051. the following tables give a summary of the instruction set cycles of the sm39 r16a3 microcontroller co re. table 2 - 1 : arithmetic operations mnemonic description code bytes cycles add a,rn add register to accumulator 28 - 2f 1 1 add a,direct add direct byte to accumulator 25 2 2 add a,@ri add indirect ram to a ccumulator 26 - 27 1 2 add a,#data add immediate data to accumulator 24 2 2 addc a,rn add register to accumulator with carry flag 38 - 3f 1 1 addc a,direct add direct byte to a with carry flag 35 2 2 addc a,@ri add indirect ram to a with carry flag 36- 37 1 2 addc a,#data add immediate data to a with carry flag 34 2 2 subb a,rn subtract register from a with borrow 98 - 9f 1 1 subb a,direct subtract direct byte from a with borrow 95 2 2 subb a,@ri subtract indirect ram from a with borrow 96 - 97 1 2 subb a,# data subtract immediate data from a with borrow 94 2 2 inc a increment accumulator 04 1 1 inc rn increment register 08 - 0f 1 2 inc direct increment direct byte 05 2 3 inc @ri increment indirect ram 06 - 07 1 3 inc dptr increment data pointer a3 1 1 dec a decrement accumulator 14 1 1 dec rn decrement register 18- 1f 1 2 dec direct decrement direct byte 15 2 3 dec @ri decrement indirect ram 16 - 17 1 3 mul ab multiply a and b a4 1 5 div divide a by b 84 1 5 da a decimal adjust accumulator d4 1 1
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 17 - tabl e 2 - 2 : logic operations mnemonic description code bytes cycles anl a,rn and register to accumulator 58 - 5f 1 1 anl a,direct and direct byte to accumulator 55 2 2 anl a,@ri and indirect ram to accumulator 56 - 57 1 2 anl a,#data and immediate data to accumulator 54 2 2 anl direct,a and accumulator to direct byte 52 2 3 anl direct,#data and immediate data to direct byte 53 3 4 orl a,rn or register to accumulator 48 - 4f 1 1 orl a,direct or direct byte to accum ulator 45 2 2 orl a,@ri or indirect ram to accumulator 46 - 47 1 2 orl a,#data or immediate data to accumulator 44 2 2 orl direct,a or accumulator to direct byte 42 2 3 orl direct,#data or immediate data to direct byte 43 3 4 xrl a,rn exclusive or regis ter to accumulator 68 - 6f 1 1 xrl a,direct exclusive or direct byte to accumulator 65 2 2 xrl a,@ri exclusive or indirect ram to accumulator 66 - 67 1 2 xrl a,#data exclusive or immediate data to accumulator 64 2 2 xrl direct,a exclusive or accumulator to direct byte 62 2 3 xrl direct,#data exclusive or immediate data to direct byte 63 3 4 clr a clear accumulator e4 1 1 cpl a complement accumulator f4 1 1 rl a rotate accumulator left 23 1 1 rlc a rotate accumulator left through carry 33 1 1 rr a rota te accumulator right 03 1 1 rrc a rotate accumulator right through carry 13 1 1 swap a swap nibbles within the accumulator c4 1 1
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 18 - table 2 - 3 : data transfer mnemonic description code bytes cycles mov a,rn move register to accumulator e8 - ef 1 1 mov a,direct move direct byte to accumulator e5 2 2 mov a,@ri move indirect ram to accumulator e6 - e7 1 2 mov a,#data move immediate data to accumulator 74 2 2 mov rn,a move accumulator to register f8 - ff 1 2 mov r n,direct move direct byte to register a8 - af 2 4 mov rn,#data move immediate data to register 78 - 7f 2 2 mov direct,a move accumulator to direct byte f5 2 3 mov direct,rn move register to direct byte 88 - 8f 2 3 mov direct1,direct2 move direct byte to dire ct byte 85 3 4 mov direct,@ri move indirect ram to direct byte 86 - 87 2 4 mov direct,#data move immediate data to direct byte 75 3 3 mov @ri,a move accumulator to indirect ram f6 - f7 1 3 mov @ri,direct move direct byte to indirect ram a6 - a7 2 5 mov @ri, #data move immediate data to indirect ram 76- 77 2 3 mov dptr,#data16 load data pointer with a 16 - bit constant 90 3 3 movc a,@a+dptr move code byte relative to dptr to accumulator 93 1 3 movc a,@a+pc move code byte relative to pc to accumulator 83 1 3 m ovx a,@ri move external ram (8 - bit addr.) to a e2 - e3 1 3 movx a,@dptr move external ram (16 - bit addr.) to a e0 1 3 movx @ri,a move a to external ram (8 - bit addr.) f2 - f3 1 4 movx @dptr,a move a to external ram (16 - bit addr.) f0 1 4 push direct push dire ct byte onto stack c0 2 4 pop direct pop direct byte from stack d0 2 3 xch a,rn exchange register with accumulator c8 - cf 1 2 xch a,direct exchange direct byte with accumulator c5 2 3 xch a,@ri exchange indirect ram with accumulator c6 - c7 1 3 xchd a,@r i exchange low - order nibble indir. ram with a d6 - d7 1 3
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 19 - table 2 - 4 : program branches mnemonic description code bytes cycles acall addr11 absolute subroutine call xxx11 2 6 lcall addr16 long subroutine call 12 3 6 ret from subroutine 22 1 4 reti from interrupt 32 1 4 ajmp addr11 absolute jump xxx01 2 3 ljmp addr16 long iump 02 3 4 sjmp rel short jump (relative addr.) 80 2 3 jmp @a+dptr jump indirect relative to the dptr 73 1 2 jz rel jump if accumulat or is zero 60 2 3 jnz rel jump if accumulator is not zero 70 2 3 jc rel jump if carry flag is set 40 2 3 jnc jump if carry flag is not set 50 2 3 jb bit,rel jump if direct bit is set 20 3 4 jnb bit,rel jump if direct bit is not set 30 3 4 jbc bit,dir ect rel jump if direct bit is set and clear bit 10 3 4 cjne a,direct rel compare direct byte to a and jump if not equal b5 3 4 cjne a,#data rel compare immediate to a and jump if not equal b4 3 4 cjne rn,#data rel compare immed. to reg. and jump if not equal b8 - bf 3 4 cjne @ri,#data rel compare immed. to ind. and jump if not equal b6 - b7 3 4 djnz rn,rel decrement register and jump if not zero d8 - df 2 3 djnz direct,rel decrement direct byte and jump if not zero d5 3 4 nop no operation 00 1 1 table 2 - 5 : boolean manipulation mnemonic description code bytes cycles clr c clear carry flag c3 1 1 clr bit clear direct bit c2 2 3 setb c set carry flag d3 1 1 setb bit set direct bit d2 2 3 cpl c compl ement carry flag b3 1 1 cpl bit complement direct bit b2 2 3 anl c,bit and direct bit to carry flag 82 2 2 anl c,/bit and complement of direct bit to carry b0 2 2 orl c,bit or direct bit to carry flag 72 2 2 orl c,/bit or complement of direc t bit to carry a0 2 2 mov c,bit move direct bit to carry flag a2 2 2 mov bit,c move carry flag to direct bit 92 2 3
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 20 - 3. memory structure the sm39 r16a3 memory structure follows general 8052 structure. it is 16kb program memory. 3.1 program memory the sm39 r16a3 has 16kb on- chip flash memory which can be used as general program memory or eeprom, on which include up to 1k byte specific isp service program memory space. the address range for the 16k byte is $0000 to $3fff. the address range for the isp ser vice program is $3c00 to $3fff. the isp service program size can be partitioned as n blocks of 128 byte (n=0 to 8). when n=0 means no isp service program space available, total 16kb memory used as program memory. when n=1 means address $3f80 to $3fff reser ved for isp service program. when n=2 means memory address $3f00 to $3fff reserved for isp service program?etc. value n can be set and programmed into sm39 r16a3 by the writer or icp. it can be used to record any data as eeprom(if you need modify the data o n program memory, please page erase first ). the procedure of this eeprom application function is described in the section 18 on internal isp n=8 n=7 n=6 n=5 n=4 n=3 n=2 n=1 n=0 3fff 3f80 3f00 3e80 3e00 3d80 3d00 3c80 3c00 0000 isp service program space, up to 1k 16k program memory space fig. 3 - 1 : sm39 r16a3 programmable fl ash
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 21 - 3.2 data memory the sm39 r16a3 has 512b on- chip sram; as below fig. 3 - 2 ; 256 bytes of it are the same as general 8052 internal memory structure . higher 128 bytes ( accessed by indirect addressing mode only ) lower 128 bytes (accessed by direct & indirect addressing mode ) sfr (accessed by direct addressing mode only) expanded 256 bytes (accessed by direct external addressing mode by instruction movx) 00 7f 80 ff 80 ff 00 ff fig. 3 - 2 : ram architecture 3.3 data memory - lower 128 byte (00h to 7fh) data memory 00h to ffh is the same as 8052. the address 00h to 7fh can be accessed by direct and indirect addressing modes. address 00h to 1fh is register area. address 20h to 2fh is memor y bit area. address 30h to 7fh is for general memory area. 3.4 data memory - higher 128 byte (80h to ffh) the address 80h to ffh can be accessed by indirect addressing mode. address 80h to ffh is data area. 3.5 data memory - expanded 256 bytes ($00 from external address 00h to ffh is the on - chip expanded sram area, total 256 bytes. this area can be accessed by external direct addressing mode (by instruction movx).
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 22 - 4. cpu engine the sm39 r16a3 engine is composed of four components: (1) control unit (2) arithmetic ? logic unit (3) memory control unit (4) ram and sfr control unit the sm39 r16a3 engine allows to fetch instruction from program memory and to execute using ram or sfr. the following chapter describes the main engine register. mnemonic description dir. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst 8051 core acc accumulator e0h acc.7 acc.6 acc.5 acc.4 acc.3 acc.2 acc.1 acc.0 00h b b register f0h b.7 b.6 b.5 b.4 b.3 b.2 b.1 b.0 00h psw program status word d0h cy ac f0 rs[1:0] ov psw.1 p 00h sp stack poin ter 81h sp[7:0] 07h dpl data pointer low 0 82h dpl[7:0] 00h dph data pointer high 0 83h dph[7:0] 00h dpl1 data pointer low 0 84h dpl1[7:0] 00h dph1 data pointer high 0 85h dph1[7:0] 00h aux auxiliary register 91h brgs - - - - - - dps 00h ckcon clock control register 8eh - its[2:0] clkout[1:0] 10h ifcon interface control register 8fh - cdpr - - - - - ispe 00h 4.1 accumulator acc is the accumulator register. most instructions use the accumulator to store the operand. mnemonic : acc address : e0h 7 6 5 4 3 2 1 0 reset acc.7 acc.6 acc05 acc.4 acc.3 acc.2 acc.1 acc.0 00h acc[7:0]: the a (or acc) register is the standard 8052 accumulator 4.2 b register the b register is used during multiply and divide instructions. it can also be used as a scratch pad register to store temporary data. mnemonic : b address : f0h 7 6 5 4 3 2 1 0 reset b.7 b.6 b.5 b.4 b.3 b.2 b.1 b.0 00h b[7:0]: the b reg ister is the standard 8052 register that serves as a second accumulator.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 23 - 4.3 program status word mnemonic : psw address : d0h 7 6 5 4 3 2 1 0 reset cy ac f0 rs [1:0] ov f1 p 00h cy: carry flag. ac: auxiliary carry flag for bcd operations. f0: general pu rpose flag 0 available for user. ov: overflow flag. f1: general purpose flag 1 available for user. p: parity flag, affected by hard ware to indicate odd/even number of ?one? bits in the accumulator, i.e. even parity 4.4 stack pointer the stack pointer is a 1 - byte register initialized to 07h after reset. this register is incremented before push and call instructions, causing the stack t o start from location 08h. mnemonic : sp address : 81h 7 6 5 4 3 2 1 0 reset sp [7:0] 07h sp[7:0]: the stack pointer stores the scratchpad ram address where the stack begins. in other words, it always points to the top of the stack. 4.5 data pointer the data pointer (dptr) is 2 - bytes wide. the lower part is dpl, and the highest is dph. it can be loaded as a 2 - byte register (e.g. mov dptr, #data16) or as two separate registers (e.g. mov dpl,#data8). it is generally used to access the external code or dat a space (e.g. movc a, @a+dptr, @dptr respectively). mnemonic : dpl address : 82h 7 6 5 4 3 2 1 0 reset dpl [7:0] 00h dpl[7:0]: data pointer low 0 mnemonic : dph address : 83h 7 6 5 4 3 2 1 0 reset dph [7:0] 00h rs[1:0] bank selected location 00 bank 0 00h ? 07h 01 bank 1 08h ? 0fh 10 bank 2 10h ? 17h 11 bank 3 18h ? 1fh
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 24 - dph [7:0]: data pointer high 0 4.6 data pointer 1 the dual data pointer accelerates the moves of data block. the standard dptr is a 16 - bit register that is used to address external memory or peripherals. in the sm39 r16a3 core the standard data pointer is called dptr, the second data pointer is called dptr1. the data pointer select bit chooses the active pointer. the data pointer select bit is located in lsb of aux register (dps). the user switches between pointers by toggling the lsb of aux register. all dptr - related instructions use the curren tly selected dptr for any activity. mnemonic : dpl1 address : 84h 7 6 5 4 3 2 1 0 reset dpl1 [7:0] 00h dpl1[7:0]: data pointer low 1 mnemonic : dph1 address : 85h 7 6 5 4 3 2 1 0 reset dph1 [7:0] 00h dph1[7:0]: data pointer high 1 mnemonic : aux ad dress : 91h 7 6 5 4 3 2 1 0 reset brgs - - - - - - dps 00h dps: data pointer select register. dps = 1 is selected dptr1. 4.7 clock control register mnemonic : ckcon address : 8eh 7 6 5 4 3 2 1 0 reset - its[2:0] - - clkout[1:0] 10h its[2:0]: instructi o n timing select . its [2:0] mode 000 1t mode 001 2t mode (default) 010 3t mode 011 4t mode 100 5t mode 101 6t mode 110 7t mode 111 8t mode
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 25 - clkout: clock output select. ckcon [1:0] mode. 00 gpio(default) 01 fosc 10 fosc/2 11 fosc/4 it can be used when the system clock is the internal rc oscillator. 4.8 interface control register mnemonic : ifcon address : 8fh 7 6 5 4 3 2 1 0 reset - cdpr - - - - - ispe 00h cdpr: code protect (read only) ispe: isp function enable bit i spe = 1, enable isp f unction ispe = 0, disable isp function
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 26 - 5. gpio 5.1 sfr setting method the sm39 r16a3 has four i/o ports: port 0, port 1, port 2, and port 3. ports 0, 1, 2 are 8 - bit ports and port 3 is a 2 - bit port. these are: quasi - bidirectional (standard 8051 port outputs), push - pull, open drain, and input - only. two configuration registers for each port select the output type for each port pin. all i/o port pins on the sm39 r16a3 may be configured by software to one of four types on a pin - by - pin basis, shown as below: mnemoni c description dir. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst i/o port function register p0m0 port 0 output mode 0 d2h p0m0 [7:0] 00h p0m1 port 0 output mode 1 d3h p0m1[7:0] 00h p1m0 port 1 output mode 0 d4h p1m0[7:0] 00h p1m1 port 1 output m ode 1 d5h p1m1[7:0] 00h p3m0 port 3 output mode 0 dah p3m0[1:0] 00h p3m1 port 3 output mode 1 dbh p3m1[1:0] 00h pxm1.y pxm0.y port output mode 0 0 quasi - bidirectional (standard 8051 port outputs) (pull - up) 0 1 push - pull 1 0 input only (high - impeda nce) 1 1 open drain the reset pin can define as general i/o p1.5 when user use internal reset. the xtal2 and xtal1 can define as p3.0 and p3.1 by writer or isp , when user use internal osc as system clock ; when user use external osc as system clock and input into xtal1 , only xtal2 can be defined as p3.0. for general - purpose applications, every pin can be assigned to either high or low independently as given below: mnemonic description dir. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst ports port 3 port 3 b0h - - - - - - p3.1 p3.0 ffh port 1 port 1 90h p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 ffh port 0 port 0 80h p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.1 p0.0 ffh mnemonic : p0 address : 80h 7 6 5 4 3 2 1 0 reset p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.1 p0 .0 ffh p0.7~ 0: port0 [7] ~ port0[0] mnemonic : p1 address : 90h 7 6 5 4 3 2 1 0 reset p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 ffh p1.7~ 0: port1 [7] ~ port1 [0]
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 27 - mnemonic : p3 address : b0h 7 6 5 4 3 2 1 0 reset - - - - - - p3.1 p3.0 ffh p3.1~ 0: por3 [1] ~ port3 [0] 5.2 software of writer setting method please setting the ?io output mode" item in the "configuration" window, it can change the i/o mode of p0~p3 to the ? quasi - bidirectional (standard 8051 port outputs) (pull - up) ? or input only (high - impedance) mode , when mcu after reset and initial . it is supported the version h of mcu after.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 28 - 6. timer 0 and timer 1 the sm39 r16a3 has three 16 - bit timer/counter registers: timer 0, timer 1 and timer 2. all can be configured for counter or timer operation s. in timer mode, the timer 0 register or timer 1 register is incremented every 1/12/96 machine cycles, which means that it counts up after every 1/12/96 periods of the clk signal. it?s dependent on sfr(pfcon). in counter mode, the register is incremente d when the falling edge is observed at the corresponding input pin t0or t1. since it takes 2 machine cycles to recognize a 1 - to - 0 event, the maximum input count rate is 1/2 of the oscillator frequency. there are no restrictions on the duty cycle, however t o ensure proper recognition of 0 or 1 state, an input should be stable for at least 1 machine cycle. four operating modes can be selected for timer 0 and timer 1. two special function registers (tmod and tcon) are used to select the appropriate mode. mne monic description dir. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst timer 0 and 1 tl0 timer 0 , low byte 8ah tl0[7:0] 00h th0 timer 0 , high byte 8ch th0[7:0] 00h tl1 timer 1 , lowbyte 8bh tl1[7:0] 00h th1 timer 1 , high byte 8dh th1[7:0] 00h tmod timer mode control 89h gate c/t m1 m0 gate c/t m1 m0 00h tcon timer/counter control 88h tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 00h pfcon peripheral frequency control register d9h - - srelps[1:0] t1ps[1:0] t0ps[1:0] 00h 6.1 timer/counter mode control register (tm od) mnemonic : tmod address : 89h 7 6 5 4 3 2 1 0 reset gate c/t m1 m0 gate c/t m1 m0 00h timer 1 timer 0 gate: if set, enables external gate control (pin int0 or int1 for counter 0 or 1, respectively). when int0 or int1 is high, and trx bit is set (s ee tcon register), a counter is incremented every falling edge on t0 or t1 input pin . c/t: selects timer or counter operation. when set to 1, a counter operation is performed, when cleared to 0, the corresponding register will function as a timer . m[1:0] : selects mode for timer/counter 0 or timer/counter 1
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 29 - m1 m0 mode function 0 0 mode0 13 - bit counter/timer, with 5 lower bits in tl0 or tl1 register and 8 bits in th0 or th1 register (for timer 0 and timer 1, respectively). the 3 high order bits of tl0 and tl1 are hold at zero. 0 1 mode1 16 - bit counter/timer. 1 0 mode2 8 - bit auto - reload counter/timer. the reload value is kept in th0 or th1, while tl0 or tl1 is incremented every machine cycle. when tlx overflows, a value from thx is copied to tlx. 1 1 mode3 if timer 1 m1 and m0 bits are set to 1, timer 1 stops. if timer 0 m1 and m0 bits are set to 1, timer 0 acts as two independent 8 bit timers / counters. 6.2 timer/counter control register (tcon) mnemonic : tcon address : 88h 7 6 5 4 3 2 1 0 reset tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 00h tf1: timer 1 overflow flag set by hardware when timer 1 overflows. this flag can be cleared by software and is automatically cleared when interrupt is processed. tr1: timer 1 run control bit. if cleared, timer 1 stops. t f0: timer 0 overflow flag set by hardware when timer 0 overflows. this flag can be cleared by software and is automatically cleared when interrupt is processed. tr0: timer 0 run control bit. if cleared, timer 0 stops. ie1: interrupt 1 edge flag. set by h ardware, when falling edge on external pin int1 is observed. cleared when interrupt is processed. it1: interrupt 1 type control bit. selects falling edge or low level on input pin to cause interrupt. it1=1, interrupt 1 select falling edge trigger. it1=0, interrupt1 select low level trigger. ie0: interrupt 0 edge flag. set by hardware, when falling edge on external pin int0 is observed. cleared when interrupt is processed. it0: interrupt 0 type control bit. selects falling edge or low level on input pin t o cause interrupt. it0=1, interrupt 0 select falling edge trigger. it0=0, interrupt 0 select low level trigger.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 30 - 6.3 enhance interrupt trigger sfr( enhit ) mnemonic : enhit address : e5h 7 6 5 4 3 2 1 0 reset - enhit1 - enhit0 - - - - 07h note : it is suppor ted the version h of mcu after. enhit1 : interrupt 1 edge trigger control bit. when enhit1 is set to 0 and it1 is set to 1 , the method of edge trigger is falling edge trigger. when enhit1 and it1 both are set to 1 , the method of edge trigger is rising edge trigger. enhit1=0 enhit1=1 it1=0 int1 low level trigger int1 low level trigger it1=1 int1 failing edge trigger int1 rising edge trigger enhit 0 : interrupt 0 edge trigger control bit. when enhit 0 is set to 0 and it 0 is set to 1 , the method of edge tr igger is falling edge trigger. when enhit 0 and it 0 both are set to 1 , the method of edge trigger is rising edge trigger. enhit0=0 enhit0=1 it0=0 int0 low level trigger in t 0 low level trigger it0=1 int0 failing edge trigger int0 rising edge trigger 6.4 p eripheral frequency control register mnemonic : pfcon address : d9h 7 6 5 4 3 2 1 0 reset - - srelps[1:0] t1ps[1:0] t0ps[1:0] 00h t1ps[1:0]: timer1 prescaler select t1ps[1:0] prescaler 00 fosc/12 01 fosc 10 fosc/96 11 reserved
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 31 - t0ps[1:0]: timer0 prescaler select t0ps[1:0] prescaler 00 fosc/12 01 fosc 10 fosc/96 11 reserved 6.5 mode 0 (13 - bit counter/timer) fig. 6 - 1 : mode 0 - 13 bit timer / counter operation 12 osc t 1 pin c / t = 0 c / t = 1 00 01 10 t 1 ps [ 1 : 0 ] t 1 ( bts ) th 1 ( bts ) t 1 ate 1 it 1 pn t r a tr 1 0 1 0 1 et 1 ea control i not er prort interrupt proessn jump 001 bh 0 1 0 1 t 1 t 1 th 1
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 32 - 6.6 mode 1 (16 - bit counter/timer) fi g. 6 - 2 : mode 1 - 16 bit timer / counter operation 6.7 mode 2 (8 - bit auto - reload counter/timer) fig. 6 - 3 : mode 2 8 bit auto - reload c ounter /timer t 1 pin c / t = 0 c / t = 1 t 1 ps [ 1 : 0 ] t 1 ( bts ) th 1 ( bts ) t 1 ate 1 it 1 pn t r a tr 1 0 1 0 1 et 1 ea auto reload 1 sc 00 01 10 control i not er prort interrupt proessn jump 001 bh
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 33 - 6.8 mode 3 (timer 0 acts as two independent 8 bit timers / counters) t 0 pin c / t = 0 c / t = 1 t 0 ps [ 1 : 0 ] tl 0 ( 8 bits ) tf 0 gate 0 / int 0 pin not or and tr 0 tr 1 th 0 ( 8 bits ) tf 1 interrupt request ( 001 bh ) 12 osc 00 01 10 96 control interrupt request ( 000 bh ) fig. 6 - 4 : mode 3 - two independent 8 bit timers / counters ( only t imer 0 )
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 34 - 7. timer 2 and capture compare unit timer 2 is not only a 16- bit timer, also a 4 - channel unit with compare, capture and reload functions. it is very similar to the programmable counter array (pca) in some other mcus except pulse width modulation (pwm). mnemoni c description dir. bit 7 bit 6 bit 5 bit 4 bit 3 b it 2 bit 1 bit 0 rst timer 2 and capture compare unit t2con timer 2 control c8h t2ps[2:0] t2r[1:0] - t2i[1:0] 00h cccon compare/capture control c9h cci3 cci2 cci1 cci0 ccf3 ccf2 ccf1 ccf 0 00h ccen compare/capture enable register c1h - cocam1[2:0] - cocam0[2:0] 00h ccen2 compare/capture enable 2 register d1h - cocam3[2:0] - cocam2[2:0] 00h tl2 timer 2, low byte cch tl2[7:0] 00h th2 timer 2, high byte cdh th2[7:0] 00h crcl compare/reload/ capture register, low byte cah crcl[7:0] 00h crch compare/ reload/ capture register, high byte cbh crch[7:0] 00h ccl1 compare/capture register 1, low byte c2h ccl1[7:0] 00h cch1 compare/capture register 1, high byte c3h cch1[7:0] 00h ccl2 compare/capture register 2, low byte c4h ccl2[7:0] 00h cch2 compa re/capture register 2, high byte c5h cch2[7:0] 00h ccl3 compare/capture register 3, low byte c6h ccl3[7:0] 00h cch3 compare/capture register 3, high byte c7h cch3[7:0] 00h
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 35 - mnemonic : t2con address : c8h 7 6 5 4 3 2 1 0 reset t2ps[2:0] t2r[1:0] - t2i[1:0] 00h t2ps[2:0]: prescaler select bit: t2ps = 000 ? timer 2 is clocked with the oscillator frequency. t2ps = 001 ? timer 2 is clocked with 1/2 of the oscillator frequency. t2ps = 010 ? timer 2 is clocked with 1/4 of the oscillator frequency. t2 ps = 011 ? timer 2 is clocked with 1/6 of the oscillator frequency. t2ps = 100 ? timer 2 is clocked with 1/8 of the oscillator frequency. t2ps = 101 ? timer 2 is clocked with 1/12 of the oscillator frequency. t2ps = 110 ? timer 2 is clocked with 1/24 of th e oscillator frequency. t2r[1:0]: timer 2 reload mode selection t2r[1:0] = 0x ? reload disabled t2r[1:0] = 10 ? mode 0: auto reload t2r[1:0] = 11 ? mode 1: t2ex falling edge reload t2i[1:0]: timer 2 input selection t2i[1:0] = 00 ? timer 2 stop t2i[1:0] = 01 ? input frequency from prescaler (t2ps[2:0]) t2i[1:0] = 10 ? timer 2 is incremented by external signal at pin t2 t2i[1:0] = 11 ? internal clock input is gated to the timer 2 mnemonic : cccon address : c9h 7 6 5 4 3 2 1 0 reset cci3 cci2 cci1 cci0 ccf 3 ccf2 ccf1 ccf0 00h cci3: compare/capture 3 interrupt control bit. ?1? is enable. cci2: compare/capture 2 interrupt control bit. ?1? is enable. cci1: compare/capture 1 interrupt control bit. ?1? is enable. cci0: compare/capture 0 interrupt control bit. ?1? is enable. ccf3: compare/capture 3 flag set by hardware. this flag can be cleared by software. ccf2: compare/capture 2 flag set by hardware. this flag can be cleared by software. ccf1: compare/capture 1 flag set by hardware. this flag can be c leared by software. ccf0: compare/capture 0 flag set by hardware. this flag can be cleared by software. compare/capture interrupt share t2 interrupt vector.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 36 - mnemonic : ccen address : c1h 7 6 5 4 3 2 1 0 reset - cocam1[2:0] - cocam0[2:0] 00h cocam1[ 2:0] 000: compare/capture disable 001: compare enable but no output on pin 010: compare mode 0 011: compare mode 1 100: capture on rising edge at pin cc1 101: capture on falling edge at pin cc1 110: capture on both rising and falling edge at pin cc1 111: c apture on write operation into register cc1 cocam0[2:0] 000: compare/capture disable 001: compare enable but no output on pin 010: compare mode 0 011: compare mode 1 100: capture on rising edge at pin cc0 101: capture on falling edge at pin cc0 110: capt ure on both rising and falling edge at pin cc0 111: capture on write operation into register cc0 mnemonic : ccen2 address : d1h 7 6 5 4 3 2 1 0 reset - cocam3[2:0] - cocam2[2:0] 00h cocam3[2:0] 000: compare/capture disable 001: compare enable but no output on pin 010: compare mode 0 011: compare mode 1 100: capture on rising edge at pin cc3 101: capture on falling edge at pin cc3 110: capture on both rising and falling edge at pin cc3 111: capture on write operation into register cc3 cocam2[2:0] 00 0: compare/capture disable 001: compare enable but no output on pin 010: compare mode 0 011: compare mode 1 100: capture on rising edge at pin cc2 101: capture on falling edge at pin cc2 110: capture on both rising and falling edge at pin cc2
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 37 - 111: capture on write operation into register cc2 7.1 timer 2 function timer 2 can operate as timer, event counter, or gated timer as explained later. 7.1.1 timer mode a s below fig. 7 - 1 ; in this mode timer 2 can by incremented in various frequency that depending on the prescaler. the prescaler is selected by bit t2ps[2:0] in register t2con. fig. 7 - 1 : timer mode and reload mode function 7.1.2 event counter mod e a s belo w fig. 7 - 2 ; in this mode, the timer is incremented when external signa l t2 change value from 1 to 0. the t2 input is sampled in every cycle. timer 2 is incremented in the cycle following the one in which the transition was detected. fig. 7 - 2 : event counter mode function
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 38 - 7.1.3 gated timer mode a s below fig. 7 - 3 ; in this mode, the internal clock which incremented timer 2 is gated by external signal t2. fig. 7 - 3 : gated timer mode function 7.1.4 reload of timer 2 reload (16 - bit reload from the crc register) can be executed in the following two modes: mode 0: reload signal is generate by a timer 2 overflows - auto reload mode 1: reload signal is gen erate by a negative transition at the corresponding input pin t2ex. 7.2 compare function in the four independent comparators, the value stored in any compare/capture register is compared with the contents of the timer register. the compare modes 0 and 1 are selected by bits c0camx . in both compare modes, the results of comparison arrives at port 1 within the same machine cycle in which the internal compare signal is activated. 7.2.1 compare mode 0 as below fig. 7 - 4 ; in mode 0, when the value in timer 2 equals the value of the compare register, the output signal changes from low to high. it goes back to a low level on timer overflow. in this mode, writing to the port will have no effect, because the input line from the i nternal bus and the write - to - latch line are disconnected. the following figure illustrates the function of compare mode 0.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 39 - fig. 7 - 4 : compare mode 0 function 7.2.2 compare mode 1 in compare mode 1, the transition of the output signal can be determined by software. a timer 2 overflow causes no output change. in this mode, both transitions of a sig nal can be controlled. fig. 7 - 5 shows a functional diagram of a register/port configuration in compare mode 1. in compare mode 1, the value is written first to the ?shadow register?, when compare signal is active, this value is transferred to the output register. fig. 7 - 5 : c omparison mode 1 function 7.3 capture function actual timer/counter contents can be saved into registers ccx or crc upon an external event (mode 0) or a software write operation (mode 1). crc or ccx contents of timer 2 reload value ccx output timer 2 = ccx value ccx output output register shadow register crc or ccx contents of timer 2 reload value ccx output timer 2 = ccx value timer 2 overflow
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 40 - 7.3.1 capture mode 0 (by hardware) a s below fig. 7 - 6 ; in mode 0, value c apture of timer 2 is executed when: (1) rising edge on input cc0 - cc3 (2) falling edge on input cc0 - cc3 (3) both rising and falling edge on input cc0 - cc3 the contents of timer 2 will be latched into the appropriate capture register. fig. 7 - 6 : capture mode 0 7.3.2 capture mode 1(by software) a s below fig. 7 - 7 ; in mode 1, value capture of timer 2 is caused by writing any value into the low - order byte of the dedicated capture register. the value written to the capture register is irrelevant to this function. the contents of timer 2 will be latched into the appropriate capture register. fig. 7 - 7 : capture mode 1 function
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 41 - 8. serial interface the se rial buffer consists of two separate registers, a transmit buffer and a receive buffer. writing data to the special function register sbuf sets this data in serial output buffer and starts the transmission. reading from the sbuf reads data from the serial receive buffer. the serial port can simultaneously transmit and receive data. it can also buffer 1 byte at receive, which prevents the receive data from being lost if the cpu reads the first byte before transmission of the second byte is completed. mnemo ni c description addres s bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst serial interface pcon power control 87h smod - - - - - stop idle 00h aux auxiliary register 91h brgs - - - - - - dps 00h scon serial port control register 98h sm0 sm1 sm2 ren tb8 rb8 ti ri 00h srell serial port reload register low byte aah srel. 7 srel. 6 srel. 5 srel. 4 srel. 3 srel. 2 srel. 1 srel. 0 00h srelh serial port reload register high byte bah - - - - - - srel. 9 srel. 8 00h sbuf serial port data buffer 99h sbuf[7:0] 00h pfcon peripheral frequency control register d9h - - srelps[1:0] t1ps[1:0] t0ps[1:0] 00h mnemonic : aux address : 91h 7 6 5 4 3 2 1 0 reset brgs - - - - - - dps 00h brgs: brgs = 0 ? baud rate generator from timer 1. brgs = 1 ? baud rate generator by srel. mnemonic : scon address : 98h 7 6 5 4 3 2 1 0 reset sm0 sm1 sm2 ren tb8 rb8 ti ri 00h sm0,sm1: serial port 0 mode selection. sm0 sm1 mode 0 0 0 0 1 1 1 0 2 1 1 3 the 4 modes in uart, mode 0 ~ 3, are explained later. sm2: enables multiproces sor communication feature ren: if set, enables serial reception. cleared by software to disable reception. tb8: the 9 th transmitted data bit in modes 2 and 3. set or cleared by the cpu depending on the function it performs such as parity check, multiproc essor communication etc. rb8: in modes 2 and 3, it is the 9 th data bit received. in mode 1, if sm2 is 0, rb8 is the stop bit. in mode 0, this bit is not used. must be cleared by software.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 42 - ti: transmit i nterrupt flag, set by hardware after completion of a serial transfer. must be cleared by software. ri: receive interrupt flag, set by hardware after completion of a serial reception. must be cleared by software. 8.1 serial interface sm0 sm1 mode description board rate 0 0 0 shift register fosc/12 0 1 1 8 - bit uart variable 1 0 2 9 - bit uart fosc/32 or fosc/64 1 1 3 9 - bit uart variable here fosc is the crystal or oscillator frequency. 8.1.1 mode 0 a s below figure. pin rxd serves as input and output. txd outputs the shift clock. 8 bits are transmitted with lsb first. the baud rate is fixed at 1/12 of the crystal frequency. reception is initialized in mode 0 by setting the flags in scon as follows: ri = 0 and ren = 1. in other modes, a start bit when ren = 1 starts receiving serial data . fig. 8 - 1 : transmit mode 0 fig. 8 - 2 : receive mode 0 8.1.2 mode 1 a s below figure. pin rxd serves as input, and txd serves as serial output. no external shift clock is used, 10 bits are tr ansmitted: a start bit (always 0), 8 data bits (lsb first), and a stop bit (always 1). on receive, a start bit synchronizes the transmission, 8 data bits are available by reading sbuf, and stop bit sets the flag rb8 in the special function register scon. i n mode 1 either internal baud rate generator or timer 1 can be use to specify baud rate.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 43 - fig. 8 - 3 : transmit mode 1 fig. 8 - 4 : receive mode 0 8.1.3 mode 2 this mode is similar to mode 1, with two differences. the baud rate is fixed at 1/32 (smod=1) or 1/64(smod=0) of oscillator frequency and 11 bits are transmitted or received: a start bit (0), 8 data bits (lsb first), a programmable 9 th bit, and a stop bit (1). the 9 th bit can be used to control the parity of the serial interface: at transmission, bit tb8 in scon is output as the 9 th bit, and at receive, the 9 th bit affects rb8 in special function register scon. 8.1.4 mode 3 a s below figure. the only difference between mo de 2 and mode 3 is that in mode 3 either internal baud rate generator or timer 1 can be use to specify baud rate. fig. 8 - 5 : transfer mode 2 and mode 3 fig. 8 - 6 : the receiving modes 2 and 3 8.2 multiprocessor communication of serial interface the feature of receiving 9 bits in modes 2 and 3 of serial interface can be used for multiprocessor communication. in
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 44 - this case, the slave processors have bit sm2 in scon s et to 1. when the master processor outputs slave?s address, it sets the 9 th bit to 1, causing a serial port receive interrupt in all the slaves. the slave processors compare the received byte with their network address. if there is a match, the addressed s lave will clear sm2 and receive the rest of the message, while other slaves will leave sm2 bit unaffected and ignore this message. after addressing the slave, the host will output the rest of the message with the 9 th bit set to 0, so no serial port receive interrupt will be generated in unselected slaves. 8.3 peripheral frequency control register mnemonic : pfcon address : d9h 7 6 5 4 3 2 1 0 reset - - srelps[1:0] t1ps[1:0] t0ps[1:0] 00h srelps[1:0]: srel prescaler select srelps[1:0] prescaler 00 fosc/64 01 fosc /32 t1ps[1:0]: timer1 prescaler select t1ps[1:0] prescaler 00 fosc/12 01 fosc 10 fosc/96 11 reserved 8.4 baud rate generator 8.4.1 serial interface modes 1 and 3 8.4.1.1 when brgs = 0 (in special function register aux). (1) t1ps[1:0] is 00 ( ) th1 256 12 32 f 2 rate baud osc smod ? = (2) t1ps[1:0] is 01 ( ) th1 256 32 f 2 rate baud osc smod ? = (3) t1ps[1:0] is 10 ( ) th1 256 96 32 f 2 rate baud osc smod ? = 8.4.1.2 when brgs = 1 (in special function register aux). (1) srelps[1:0] is 00
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 45 - ( ) ? = (2) srelps[1:0] is 01 ( ) srel 2 32 f 2 rate baud 10 osc smod ? =
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 46 - 9. watchdog timer the watch dog timer (wdt) is an 8 - bit free - running counter that generate reset signal if the counter overflows. the wdt is useful for systems which are susceptible to noise, power glitches, or electronics discharge which causing software dead loop or runaway. the wdt f unction can help user software recover from abnormal software condition. the wdt is different from timer0, timer1 and timer2 of general 8052. to prevent a wdt reset can be done by software periodically clearing the wdt counter. user should check wdtf bit o f wdtc register whenever un - predicted reset happened. after an external reset the watchdog timer is disabled and all registers are set to zeros. the watchdog timer has a free r unning on - chip rc oscillator (2 3 khz). the wdt will keep on running even after the system clock has been turned off (for example, in sleep mode). during normal operation or sleep mode, a wdt time - out (if enabled) will cause the mcu to reset. the wdt can be enabled or disabled any time during the normal mode. please refer the wdte bit of wdtc register. the default wdt time - out period is approximately 1 78.0 m s (wdtm [3:0] = 0100b). the wdt has selectable divider input for the time base source clock. to select the divider input, the setting of bit3 ~ bit0 (wdtm [3:0]) of watch dog timer control register (wdtc) should be set accordingly. wdtm 2 23khz = wdtclk watchdog reset time = wdtclk 256 table 9 - 1 : wdt time - out period wdtm [3:0] divider (2 3 khz rc oscillator in) time pe riod @ 2 3 khz 0000 1 1 1.1 ms 0001 2 22.2 ms 0010 4 44.5 ms 0011 8 89. 0 ms 0100 16 178.0 ms (default) 0101 32 356.1 ms 0110 64 712.3 ms 0111 128 1. 4246 s 1000 256 2.8493 s 1001 512 5.6987 s 1010 1024 11.397 s 1011 2048 22.795 s 1100 4096 45.590 s 1101 8192 91.180 s 1110 16384 182.36 s 1111 32768 364.72 s when mcu is reset, the mcu will be read wdten control bit status. when wdten bit is set to 1, the watchdog function will be disabled no matter what the wdte bit status is. when wdten bit is clear to 0, the watchdog function will be enabled if wdte bit is set to 1 by program. user can to set wdten on the writer or isp. the program can enable the wdt function by programming 1 to the wdte bit premise that wdten control bit is clear to 0. after wdte set to 1, t he 8 bit - counter starts to count with the selected time base source clock which set by wdtm [3:0]. it will generate a reset signal when overflows. the wdte bit will be cleared to 0 automatically when mcu been reset, either hardware reset or wdt reset. once the watchdog is started it cannot be stopped. user can refreshed the watchdog timer to zero by writing 0x55 to
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 47 - watch dog timer refresh key (wdtk) register. this will clear the content of the 8 - bit counter and let the counter re - start to count from the beg inning. the watchdog timer must be refreshed regularly to prevent reset request signal from becoming active. when watchdog timer is overflow, the wdtf flag will set to one and automatically reset mcu. the wdtf flag can be clear by software or external res et or power on reset. 23khz rc oscillator wdtm 2 1 wdtc takey (55, aa, 5a) wdtm[3:0] wdten enable/disable wdt wdt counter wdtclk wdtk (0x55) refresh wdt counter 1. power on reset 2. external reset 3. software write ?0? wdtf set wdtf = 1 clear wdtf = 0 wdt time-out reset enable wdtc write attribute wdt time-out select wdt time-out interrupt cwdtr = 0 cwdtr = 1 fig. 9 - 1 : watchdog timer block diagram mnemon ic description addre ss bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst watchdog timer takey time access k ey register f7h takey [7:0] 00h wdtc watchdog timer control register b6h - cwdtr wdte - wdtm [3:0] 04h wdtk watchdog timer refresh key b7h wdtk[7:0] 00h rsts reset status register a1h - - - pdrf wdtf swrf lvrf porf 00h mnemonic : takey address : f7h 7 6 5 4 3 2 1 0 reset takey [7:0] 00h watchdog timer control register (wdtc) is read - only by default; software must write three specific values 55h, aah and 5ah sequentially to the takey register to enable the wdtc write attribute. that is mov takey, # 55h mov takey, #0aah mov takey, #5ah
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 48 - mnemonic : wdtc address : b6h 7 6 5 4 3 2 1 0 reset - cwdtr wdte - wdtm [3:0] 04h cwdtr: watch dog states select bit(support stop mode wakeup) 0: enable watch dog reset. 1: enable watch dog interrupt. wdte: control bit used to enable watchdog timer. the wdte bit can be used only if wdten is "0". if the wdten bit is "0", then wdt can be disabled / enabled by the wdte bit. 0: disable wdt. 1: enable wdt. the wdte bit is not used if wdten is "1". that is, if the wdten b it is "1", wdt is always disabled no matter what the wdte bit status is. the wdte bit can be read and written. wdtm [3:0]: wdt clock source d ivider bit. please see table 9 - 1 to reference the wdt time - out period. mnemonic : rsts address : a1h 7 6 5 4 3 2 1 0 reset - - - pdrf wdtf swrf lvrf porf 00h wdtf: watchdog timer reset flag. when mcu is reset by watchdog, wdtf flag will be set to one by hardware. this flag clear by software mnemonic : wdtk address : b7h 7 6 5 4 3 2 1 0 reset wdtk[7:0] 00h wdtk: watchdog timer refresh key. a programmer must write 0x55 into wdtk register, and then the watchdog timer will be cleared to zero. for example 1, if enable wdt and select time - out reset period is 2.8493 s . first, programming th e information block op3 bit7 wdten to ?0?. secondly, mov takey, #55h mov takey, #0aah mov takey, #5ah ; enable wdtc write attribute. mov wdtc, #28h ; set wdtm [3:0] = 1000b. set wdte =1 to enable wdt ; function. . .
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 49 - . mov wdtk, #55h ; clear wdt timer to 0. . . for example 2, if enable wdt and select time - out interrupt period is 178.0m s. first, programming the information block op3 bit7 wdten to ?0?. secondly, mov takey, #55h mov takey, #0aah mov takey, #5ah ; enable wdtc write attribute. mov wd tc, #64h ; set wdtm [3:0] = 01 00b. set wdte =1 to enable wdt function ; and set cwdtr =1 to enable period interrupt function
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 50 - 10. interrupt the sm39 r16a3 provides 14 interrupt sources with four priority levels. each source has its own request fla g(s) located in a special function register. each interrupt requested by the corresponding flag could individually be enabled or disabled by the enable bits in sfr?s ien0, ien1, and ien2. when the interrupt occurs, the engine will vector to the predetermi ne d address as shown in table 10- 1 . once interrupt service has begun, it can be interrupted only by a higher priority interrupt. the interrupt service is terminated by a return from instruction reti. when an reti is performed, the processor will return to the instruction that would have been next when interrupt occurred. when the interrupt condition occurs, the processor will also indicate this by setting a flag bit. this bit is set regardless of whether the interrupt is enabled o r disabled. each interrupt flag is sampled once per machine cycle, and then samples are polled by hardware. if the sample indicates a pending interrupt when the interrupt is enabled, then interrupt request flag is set. on the next instruction cycle the int errupt will be acknowledged by hardware forcing an lcall to appropriate vector address. interrupt response will require a varying amount of time depending on the state of microcontroller when the interrupt occurs. if microcontroller is performing an inter rupt service with equal or greater priority, the new interrupt will not be invoked. in other cases, the response time depends on current instruction. the fastest possible response to an interrupt is 7 machine cycles. this includes one machine cycle for det ecting the interrupt and six cycles for perform the lcall. table 10- 1 : interrupt vectors interrupt request flags interrupt vector address interrupt number *(use keil c tool) 1 ie0 ? external interrupt 0 000 3h 0 2 tf0 ? timer 0 interrupt 000bh 1 3 ie1 ? external interrupt 1 0013h 2 4 tf1 ? timer 1 interrupt 001bh 3 5 ri/ti ? serial channel interrupt 0023h 4 6 tf2/exf2 ? timer 2 interrupt 002bh 5 7 pwmif ? pwm interrupt 0043h 8 8 spiif ? spi i nterrupt 004bh 9 9 adcif ? a/d converter interrupt 0053h 10 10 kbiif ? keyboard interface interrupt 005bh 11 11 lviif ? low voltage interrupt 0063h 12 12 iicif ? iic interrupt 006bh 13 13 wdtif ? watchdog interrupt 008bh 17 14 comparator inte rrupt 0093h 18 * see keil c about c51 user?s guide about interrupt function description
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 51 - mnemonic description dir. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst interrupt ien0 interrupt enable 0 register a8h ea - et2 es et1 ex1 et0 ex0 00h ie n1 interrupt enable 1 register b8h exen 2 - ieiic ielvi iekbi ieadc iespi iepw m 00h ien2 interrupt enable 2 register 9ah - - - - - ecmpi ewdt t - 00h ircon interrupt request register c0h exf2 tf2 iicif lviif kbiif adcif spiif pwmi f 00h ircon2 interrupt request register 2 97h - - - - - cmpif wdti f - 00h ip0 interrupt priority level 0 a9h - - ip0.5 ip0.4 ip0.3 ip0.2 ip0.1 ip0.0 00h ip1 interrupt priority level 1 b9h - - ip1.5 ip1.4 ip1.3 ip1.2 ip1.1 ip1.0 00h interrupt enable 0 register(ien0) mnem onic : ien0 address : a8h 7 6 5 4 3 2 1 0 reset ea - et2 es0 et1 ex1 et0 ex0 00h ea: ea=0 ? disable all interrupt. ea=1 ? enable all interrupt. et2: et2=0 ? disable timer 2 overflow or external reload interrupt. et2=1 ? enable timer 2 overflow or extern al reload interrupt. es: es=0 ? disable serial channel interrupt. es=1 ? enable serial channel interrupt. et1: et1=0 ? disable timer 1 overflow interrupt. et1=1 ? enable timer 1 overflow interrupt. ex1: ex1=0 ? disable external interrupt 1. ex1=1 ? enab le external interrupt 1. et0: et0=0 ? disable timer 0 overflow interrupt. et0=1 ? enable timer 0 overflow interrupt. ex0: ex0=0 ? disable external interrupt 0. ex0=1 ? enable external interrupt 0.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 52 - interrupt enable 1 register (ien1) mnemonic : ien1 add ress : b8h 7 6 5 4 3 2 1 0 reset exen2 - ieiic ielvi iekbi ieadc iespi iepwm 00h exen2: timer 2 reload interrupt enable. exen2 = 0 ? disable timer 2 external reload interrupt. exen2 = 1 ? enable timer 2 external reload interrupt. ieiic: iic interrupt e nable. ieiics = 0 ? disable iic interrupt. ieiics = 1 ? enable iic interrupt. ielvi: lvi interrupt enable. ielvi = 0 ? disable lvi interrupt. ielvi = 1 ? enable lvi interrupt. iekbi: kbi interrupt enable. iekbi = 0 ? disable kbi interrupt. iekbi = 1 ? en able kbi interrupt. ieadc: a/d converter interrupt enable ieadc = 0 ? disable adc interrupt. ieadc = 1 ? enable adc interrupt. iespi: spi interrupt enable. iespi = 0 ? disable spi interrupt. iespi = 1 ? enable spi interrupt. iepwm: pwm interrupt enable. iepwm = 0 ? disable pwm interrupt. iepwm = 1 ? enable pwm interrupt. interrupt enable 2 register (ien2) mnemonic : ien2 address : 9ah 7 6 5 4 3 2 1 0 reset - - - - - ecmpi ewdt t - 00h ecmpi enable comparator interrupt(include comparator_0 and compar ator_1). ecmpi = 0 ? disable comparator interrupt. ecmpi = 1 ? enable comparator interrupt. ewdt t: enable watch dog interrupt. ewdt t = 0 ? disable watch dog interrupt. ewdt t = 1 ? enable watch dog interrupt.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 53 - interrupt request register(ircon) mnemonic : ircon address : c0h 7 6 5 4 3 2 1 0 reset exf2 tf2 iicif lviif kbiif adcif spiif pwmif 00h exf2: timer 2 external reload flag. must be cleared by software. tf2: timer 2 overflow flag. must be cleared by software. iicif: iic interrupt flag. lviif: lv i interrupt flag. kbiif: kbi interrupt flag. adcif: a/d converter end interrupt flag. spiif: spi interrupt flag. pwmif: pwm interrupt flag. must be cleared by software. interrupt request register 2 (ircon2) mnemonic : ircon2 address : 97h 7 6 5 4 3 2 1 0 reset - - - - - cmpif wdtif - 00h cmpif comparator interrupt flag hw will clear this flag automatically when enter interrupt vector. sw can clear this flag also.(in case analog comparator int disable) wdtif: watch dog interrupt flag 10.1 priority le vel structure all interrupt sources are combined in groups: table 10- 2 : priority level groups groups external interrupt 0 - pwm interrupt timer 0 interrupt watchdog interrupt spi interrupt external int errupt 1 comparator interrupt adc interrupt timer 1 interrupt - kbi interrupt serial channel interrupt - lvi interrupt timer 2 interrupt - iic interrupt each group of interrupt sources can be programmed individually to one of four priority level s by setting or clearing one bit in the special function register ip0 and one in ip1. if requests of the same priority level will be received simultaneously, an internal polling sequence determines which request is serviced first mnemonic : ip0 address : a 9h 7 6 5 4 3 2 1 0 reset - - ip0.5 ip0.4 ip0.3 ip0.2 ip0.1 ip0.0 00h
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 54 - mnemonic : ip1 address : b9h 7 6 5 4 3 2 1 0 reset - - ip1.5 ip1.4 ip1.3 ip1.2 ip1.1 ip1.0 00h table 10- 3 : priority levels ip1.x ip0.x priority level 0 0 level0 (lowest) 0 1 level1 1 0 level2 1 1 level3 (highest) table 10- 4 : groups of priority bit group ip1.0, ip0.0 external interrupt 0 - pwm interrupt ip1.1, ip0.1 timer 0 interrupt watchdog interrupt spi interrupt ip1.2, ip0.2 external interrupt 1 comparator interrupt adc interrupt ip1.3, ip0.3 timer 1 interrupt - kbi interrupt ip1.4, ip0.4 serial channel interrupt - lvi interrupt ip1.5, ip0.5 timer 2 interrupt - iic interrupt table 10- 5 : polling sequence interrupt source sequence external interrupt 0 pwm interrupt timer 0 interrupt watchdog interrupt spi interrupt external interrupt 1 comparator interrupt adc inte rrupt timer 1 interrupt kbi interrupt serial channel interrupt lvi interrupt timer 2 interrupt iic interrupt polling sequence
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 55 - 11. power management unit power management unit serves two power management modes, idle and stop, for the users to do power saving fu nction. mnemonic : pcon address : 87h 7 6 5 4 3 2 1 0 reset smod - - - - - stop idle 00h stop: stop mode control bit. setting this bit turning on the stop mode. stop bit is always read as 0 idle: idle mode control bit. setting this bit turning on the idle mode. idle bit is always read as 0 11.1 idle mode setting the idle bit of pcon register invokes the idle mode. the idle mode leaves internal clocks and peripherals running. power consumption drops because the cpu is not active. the cpu can exit the idle state with any interrupts or a reset. 11.2 stop mode setting the stop bit of pcon register invokes the stop mode. all internal clocking in this mode is turn off. the cpu will exit this state from a no - clocked interrupt (external int0/1 and lvi , kbi, comparat or interrupt , watchdog interrupt) or a reset (wdt and lvr) condition. internally generated interrupts (timer, serial port ...) have no effect on stop mode since they require clocking activity.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 56 - 12. pulse width modulation (pwm) sm39 r16a3 provides two - channel pwm outputs. the interrupt vector is 43h. mnemonic description dir. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst pwm pwmc pwm control register b5h pwmcs[2:0] - pwm3 en pwm2 en pwm1 en pwm0 en 00h pwmd0h pwm 0 data register high byte bch pwmp 0 - - - - - pwmd0[9:8] 00h pwmd0l pwm 0 data register low byte bdh pwmd0[7:0] 00h pwmd1h pwm 1 data register high byte beh pwmp 1 - - - - - pwmd1[9:8] 00h pwmd1l pwm 1 data register low byte bfh pwmd1[7:0] 00h pwmd2h pwm 2 data register high byte b1h pw mp 2 - - - - - pwmd2[9:8] 00h pwmd2l pwm 2 data register low byte b2h pwmd2[7:0] 00h pwmd3h pwm 3 data register high byte b3h pwmp 3 - - - - - pwmd3[9:8] 00h pwmd3l pwm 3 data register low byte b4h pwmd3[7:0] 00h pwmmdh pwm max data register high byt e ceh - - - - - - pwmmd[9:8] 00h pwmmdl pwm max data register low byte cfh pwmmd[7:0] ffh mnemonic: pwmc address: b5h 7 6 5 4 3 2 1 0 reset pwmcs[2:0] - pwm3en pwm2en pwm1en pwm 0 en 00h pwmcs[2:0]: pwm clock select . pwmcs [2:0] mode 000 fosc 001 fosc/2 010 fosc/4 011 fosc/6 100 fosc/8 101 fosc/12 110 timer 0 overflow 111 timer 0 external input (p3.4/t0) pwm3en pwm channel 3 enable control bit. pwm3en = 1 ? pwm channel 1 enable. pwm3en = 0 ? pwm channel 1 disable. pwm2en pwm channel 2 ena ble control bit. pwm2en = 1 ? pwm channel 1 enable. pwm2en = 0 ? pwm channel 1 disable.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 57 - pwm1en: pwm channel 1 enable control bit. pwm1en = 1 ? pwm channel 1 enable. pwm1en = 0 ? pwm channel 1 disable. pwm0en: pwm 0 enable control bit. pwm0en = 1 ? pwm ch annel 0 enable. pwm0en = 0 ? pwm channel 0 disable. mnemonic : pwmd0h address : bch 7 6 5 4 3 2 1 0 reset pwmp0 - - - - - pwmd0[9:8] 00h mnemonic : pwmd0l address : bdh 7 6 5 4 3 2 1 0 reset pwmd0[7:0] 00h pwmp0: pwm channel 0 idle polarity select. ? 0? ? pwm channel 0 will idle low. ?1? ? pwm channel 0 will idle high. pwmd0[9:0]: pwm channel 0 data register. mnemonic : pwmd1h address : beh 7 6 5 4 3 2 1 0 reset pwmp1 - - - - - pwmd1[9:8] 00h mnemonic : pwmd1l address : bfh 7 6 5 4 3 2 1 0 reset p wmd1[7:0] 00h pwmp1: pwm channel 1 idle polarity select. ?0? ? pwm channel 1 will idle low. ?1? ? pwm channel 1 will idle high. pwmd1[9:0]: pwm channel 1 data register. mnemonic : pwmd2h address : b1h 7 6 5 4 3 2 1 0 reset pwmp 2 - - - - - pwmd 2 [9:8] 0 0h mnemonic : pwmd2l address : b2h 7 6 5 4 3 2 1 0 reset pwmd2[7:0] 00h pwmp2: pwm channel 2 idle polarity select. ?0? ? pwm channel 2 will idle low. ?1? ? pwm channel 2 will idle high. pwmd2[9:0]: pwm channel 2 data register.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 58 - mnemonic : pwmd3h addre ss : b3h 7 6 5 4 3 2 1 0 reset pwmp3 - - - - - pwmd 3 [9:8] 00h mnemonic : pwmd3l address : b4h 7 6 5 4 3 2 1 0 reset pwmd3[7:0] 00h pwmp3: pwm channel 3 idle polarity select. ?0? ? pwm channel 3 will idle low. ?1? ? pwm channel 3 will idle high. pwmd3 [9:0]: pwm channel 3 data register. mnemonic : pwmmdh address : ceh 7 6 5 4 3 2 1 0 reset - - - - - - pwmmd[9:8] 00h mnemonic : pwmmdl address : cfh 7 6 5 4 3 2 1 0 reset pwmmd[7:0] ffh pwmmd[9:0]: pwm max data register. pwm count from 0000h to pwmmd [9:0]. when pwm count da ta equal pwmmd[9:0] is overflow . pwmpx = 0 & pwmdx = 00h low pwmx pwmpx = 0 & pwmdx 00h pwmx pwmpx = 1 & pwmdx = 00h high pwmx pwmpx = 1 & pwmdx 00h pwmx clock pwm 1 pwmmd period pwm + = clock pwm pwmdx pulse leader =
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 59 - 13. iic function the iic module uses the scl ( clock) and the sda (data) line to communicate with external iic interface. its speed can be selected to 400kbps (maximum) by software setting the iicbr [2:0] control bit. the iic module provided 2 interrupts (rxif, txif). it will generate start, repeated s tart and stop signals automatically in master mode and can detects start, repeated start and stop signals in slave mode. the maximum communication length and the number of devices that can be connected are limited by a maximum bus capacitance of 400pf. th e interrupt vector is 6bh. mnemonic description dir. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst iic function aux auxiliary register 91h brgs - - - dps 00h iicctl iic control register f9h iicen mss mas ab_e n bf_en iicbr[2:0] 04h iics iic s tatus register f8h - mpif laif rxif txif rxak txak rw or bb 00h iica1 iic address 1 register fah iica1[7:1] matc h1or rw1 a0h iica2 iic address 2 register fbh iica2[7:1] matc h2 or rw2 60h iicrwd iic read/write register fch iicrwd[7:0] 00h iicebt iic enaable bus transaction fdh fu_en - - - - - - 00h mnemonic: iicctl address: f9h 7 6 5 4 3 2 1 0 reset iicen mss mas ab_en bf_en iicbr[2:0] 04h iicen: enable iic module iicen = 1 is enable iicen = 0 is disable. mss: master or slave mode select. mss = 1 is master mode. mss = 0 is slave mode. *the software must set this bit before setting others register. mas: master address select (master mode only) mas = 0 is to use iica1. mas = 1 is to use iica2. ab_en: arbitration lost enable bit. (master mode only) if set ab_en bit, the hardware will check arbitration lost. once arbitration lost occurred, hardware will return to idle state. if this bit is cleared, hardware will not care arbitration lost condition. set this bit when multi - master and slave conne ction. clear this bit when single master to single slave. bf_en: bus busy enable bit. (master mode only) if set bf_en bit, hardware will not generate a start condition to bus until bf=0. clear this bit
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 60 - will always generate a start condition to bus when ms tart is set. set this bit when multi - master and slave connection. clear this bit when single master to single slave. iicbr[2:0]: baud rate selection (master mode only), where fosc is the external crystal or oscillator frequency. the default is fosc/512 f or users? convenience. iicbr[2:0] baud rate 000 fosc/32 001 fosc/64 010 fosc/128 011 fosc/256 100 fosc/512 101 fosc/1024 110 fosc/2048 111 fosc/4096 mnemonic: iics address: f8h 7 6 5 4 3 2 1 0 reset - mpif laif rxif txif rxak txak rw or bb 0 0h mpif: the stop condition interrupt flag the stop condition occurred and this bit will be set. software need to clear this bit laif: arbitration lost bit. (master mode only) the arbitration interrupt flag, the bus arbitration lost occurred and this b it will be set. software need to clear this bit rxif: the data receive interrupt flag (rxif) is set after the iicrwd (iic read write data buffer) is loaded with a newly receive data. txif: the data transmit interrupt flag (txif) is set when the data of t he iicrwd (iic read write data buffer) is downloaded to the shift register. rxak: the acknowledge status indicate bit. when clear, it means an acknowledge signal has been received after the complete 8 bits data transmit on the bus. txak: the acknowledge status transmit bit. when received complete 8 bits data, this bit will set (noack) or clear (ack) and transmit to master to indicate the receive status. rw or bb: master mode: bb : bus busy bit if detect scl=0 or sda=0 or bus start, this bit will be set. if detect stop,this bit will be cleared. this bit can be cleared by software to return ready state. slave mode: rw:the slave mode read (received) or wrote (transmit) on the iic bus. when this bit is clear, the slave module received data on the iic bus (sd a).(slave mode only)
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 61 - fig. 13 - 1: acknowledgement bit in the 9 th bit of a byte transmission mnemonic: iica1 address: fah 7 6 5 4 3 2 1 0 reset iica1[7:1] match1 or rw1 a0h r/w r or r/w slave mode: iica1[7:1]: iic address registers this is the first 7 - bit address for this slave module. it will be checked when an address (from master) is received match1: when iica1 matches with the received address from the master side, this bit will set to 1 by hardware. when iic bus gets first data, this bit will clear. master mode: iica1[7:1]: iic address registers this 7 - bit address indicates the slave with which it wants to communicate. rw1: this bit will be sent out as rw of the slave side if the module has set the mstart or rstart bit. it appears at the 8 th bit after the iic address as shown in fig. 13 - 2. it is used to tell the salve the direction of the following communication. if it is 1, the module is in master receive mode. if 0, the module is in master transmit mode. rw1=1, master receive mode rw1=0, master transmit mode
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 62 - fig. 13 - 2: rw bit in the 8 th bit after iic address mnemonic: iica2 address: fbh 7 6 5 4 3 2 1 0 reset iica2[7:1] match2 or rw2 60h r/w r or r/w slave mode: iica2[7:1]: iic address registers this is the second 7 - b it address for this slave module. it will be checked when an address (from master) is received match2: when iica2 matches with the received address from the master side, this bit will set to 1 by hardware. when iic bus gets first data, this bit will cle ar. master mode: iica2[7:1]: iic address registers this 7 - bit address indicates the slave with which it wants to communicate. rw2: this bit will be sent out as rw of the slave side if the module has set the mstart or rstart bit. it is used to tell the salve the direction of the following communication. if it is 1, the module is in master receive mode. if 0, the module is in master transmit mode. rw2=1, master receive mode rw2=0, master transmit mode mnemonic: iicrwd address: fch 7 6 5 4 3 2 1 0 res et iicrwd[7:0] 00h iicrwd[7:0]: iic read write data buffer. in receiving (read) mode, the received byte is stored here. in transmitting mode, the byte to be shifted out through sda stays here. mnemonic: iicebt address: fdh 7 6 5 4 3 2 1 0 reset f u_e n - - - - - - 00h master mode :
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 63 - 00: reserved 01: iic bus module will enable read/write data transfer on sda and scl. 10: iic bus module generate a start condition on the sda/scl, then send out address which is stored in the iica1/iica2(selected by mas c ontrol bit) 11: iic bus module generates a stop condition on the sda/scl. fu_en[7:6] will be auto - clear by hardware, so setting fu_en[7:6] repeatedly is necessary. slave mode: 01: fu_en[7:6] should be set as 01 only. the other value is inhibited. notic e: 1. fu_en[7:6] should be set as 01 before read/write data transfer for bus release; otherwise, scl will be locked(pull low). 2. fu_en[7:6] should be set as 01 after read/write data transfer for receiving a stop condition from bus master. 3. in transmit data mode( slave mode), the output data should be filled into iicrwd before setting fu_en[7:6] as 01. 4. fu_en[7:6] will be auto - clear by hardware, so setting fu_en[7:6] repeatedly is necessary.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 64 - 14. spi function - serial peripheral interface serial peripheral interface ( spi) is a synchronous protocol that allows a master device to initiate communication with slave devices. the interrupt vector is 4bh. there are 4 signals used in spi, they are spi_mosi: data output in the master mode, data input in the slave mode, spi_m iso: data input in the master mode, data output in the master mode, spi_sck: clock output from the master, the above data are synchronous to this signal spi_ss: input in the slave mode. this slave device detects this signal to judge if it is selected by the master. in the master mode, it can select the desired slave device by a ny io with value = 0. fig. 14 - 1 is an example showing the relation of the 4 signals between master and slaves. fig. 14 - 1 : spi signals between master and slave devices there is only one channel spi interface. the spi sfrs are shown as below: spi description addr ess bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst spi function spic1 spi control r egister 1 f1h spie n spims s spiss p spick p spick e spibr[2:0] 08h spic2 spi control register 2 f2h spif d tbc[2:0] spirs t rbc[2:0] 00h spis spi status register f5h spir f spiml s spiov spitx if spitd r spirx if spird r spirs 40h spitxd spi transmit data buffer f3h spitxd[7:0] 00h spirxd spi receive data buffer f4h spirxd[7:0] 00h mnemonic : spic1 address : f1h 7 6 5 4 3 2 1 0 reset spien spimss spissp spickp spicke spibr[2:0] 08h master mosi miso clk io io slave 1 mosi m iso clk ss slave 2 mosi miso clk ss
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 65 - spien: enable spi module. ?1? is enable. ?0? is disable. spimss: master or slave mode select ?1? is master mode. ?0? is slave mode. spissp: ss or cs active polarity.(slave mode used only) ?1? - high active. ?0? - low active. spickp: clock idle polarity select. ?1? - sck will idle high. ex : ?0? - sck will idle low. ex : spicke: clock sample edge select. ?1? ? rising edge latch data. ?0? ? falling edge latch data. * to ensure the data latch stability, sm39 r16a3 generate the output data as given in the following example, the other side can latch the stable data no matte r in rising or falling edge. spibr[2:0]: spi baud rate select. (master mode used only) spibr[2:0] baud rate 0:0:0 fosc/4 0:0:1 fosc /8 0:1:0 fosc /16 0:1:1 fosc /32 1:0:0 fosc /64 1:0:1 fosc /128 1:1:0 fosc /256 1:1:1 fosc /512 sufficient set - up time sufficient hold time
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 66 - mnemon ic : spic2 address : f2h 7 6 5 4 3 2 1 0 reset spifd tbc[2:0] spirst rbc[2:0] 00h spifd: full - duplex mode enable. ?1? is enable full - duplex mode. ?0? is disable full - duplex mode. when it is set, the tbc[2:0] and rbc[2:0] will be reset and keep to zero. w hen the master device transmits data to the slave device via the mosi line, the slave device responds by sending data to the master device via the miso line. this implies full - duplex transmission with both data out and data in synchronized with the same cl ock. input shift register spirxd output shift register spitxd clock generator output shift register spitxd syncmos master input shift register spirxd syncmos slave miso mosi sck miso mosi sck fig. 14 - 2 : spi master and slave transmission method tbc[2:0]: spi transmitter bit counter. tbc[2:0] bit counter 0:0:0 8 bits output 0:0:1 1 bit output 0:1:0 2 bits outp ut 0:1:1 3 bits output 1:0:0 4 bits output 1:0:1 5 bits output 1:1:0 6 bits output 1:1:1 7 bits output spirst: spi re - start (slave mode used only) spirst=0:re - start function disable.spi transmit/receive data when ss active. in spitxd/spirxd buffer, data got from previous ss active period will not be removed (i.e. it's valid). spirst=1:re - start function enable.spi transmit/receive new data when ss re - active; in spitxd/spirxd buffer, data got from previous ss active period will be removed (i.e. it's i nvalid).
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 67 - rbc[2:0]: spi receiver bit counter. rbc[2:0] bit counter 0:0:0 8 bits input 0:0:1 1 bit input 0:1:0 2 bits input 0:1:1 3 bits input 1:0:0 4 bits input 1:0:1 5 bits input 1:1:0 6 bits input 1:1:1 7 bits input mnemonic : spis address :f5h 7 6 5 4 3 2 1 0 reset spirf spimls spiov spitxif spitdr spirxif spirdr spirs 40h spirf: spi ss pin release flag. this bit is set when ss pin release & spirst as ?1?. spimls: msb or lsb first output /input select. ?1? is msb first output/input. ?0? is lsb first output/input. spiov: overflow flag. when spirdr is set and next data already into shift register, this flag will be set. it is clear by hardware, when spirdr is cleared. spitxif: transmit interrupt flag. this bit is set when the data of the sp itxd register is downloaded to the shift register. spitdr: transmit data ready. when mcu finish writing data to spitxd register, the mcu needs to set this bit to ?1? to inform the spi module to send the data. after spi module finishes sending the data fro m spitxd, this bit will be cleared automatically. spirxif: receive interrupt flag. this bit is set after the spirxd is loaded with a newly receive data. spirdr: receive data ready. the mcu must clear this bit after it gets the data from spirxd register. the spi module is able to write new data into spirxd only when this bit is cleared. spirs: receive start. this bit set to ?1? to inform the spi module to receive the data into spirxd register.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 68 - mnemonic : spitxd address : f3h 7 6 5 4 3 2 1 0 reset spit xd[7:0] 00h spitxd[7:0]: transmit data buffer. mnemonic : spirxd address : f4h 7 6 5 4 3 2 1 0 reset spirxd[7:0] 00h spirxd[7:0]: receive data buffer . p.s. miso pin must be float when ss or cs no - active in slave mode.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 69 - 15. kbi ? keyboard interface ke yboard interface (kbi) can be connected to a 4 x n matrix keyboard or any similar devices. it has 4 inputs with programmable interrupt capability on either high or low level. these 4 inputs can be the external interrupts to leave from the idle and stop mod es. kbi 0 or input circuitry input circuitry input circuitry input circuitry kbi1 kbi2 kbi3 iekbi: kbi interrupt enable kbiif: kbi interrupt flag fig. 15 - 1 : k eyboard interface block diagram de-bounce kbix 250khz kbd[1:0] 0 1 kbf.x kbls.x kbe.x fig. 15 - 2 : keyboard input circuitry mnemonic descrip tion dir. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst kbi function kbls kbi level selection 93h - - - - kbls3 kbls2 kbls1 kbls0 00h kbe kbi input enable 94h - - - - kbe3 kbe2 kbe1 kbe0 00h kbf kbi flag 95h - - - - kbf3 kbf2 kbf1 kbf0 00h kbd kbi de - bounce control register 96h kbde n - - - - - kbd1 kbd0 00h
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 70 - mnemonic : kbls address : 93h 7 6 5 4 3 2 1 0 reset - - - - kbls.3 kbls.2 kbls.1 kbls.0 00h kbls.3: keyboard line 3 level selection bit 0 : enable a low level detection on kbi3. 1 : enable a high level detection on kbi3. kbls.2: keyboard line 2 level selection bit 0 : enable a low level detection on kbi2. 1 : enable a high level detection on kbi2. kbls.1: keyboard line 1 level selection bit 0 : enable a low level detection on kbi1. 1 : enable a high level detection on kbi1. kbls.0: keyboard line 0 level selection bit 0 : enable a low level detection on kbi0. 1 : enable a high level detection on kbi0. mnemonic : kbe address : 94h 7 6 5 4 3 2 1 0 reset - - - - kbe.3 kbe.2 kbe.1 kbe. 0 00h kbe.3: keyboard line 3 enable bit 0 : enable standard i/o pin. 1 : enable kbf.3 bit in kbf register to generate an interrupt request. kbe.2: keyboard line 2 enable bit 0 : enable standard i/o pin. 1 : enable kbf.2 bit in kbf register to generate a n interrupt request. kbe.1: keyboard line 1 enable bit 0 : enable standard i/o pin. 1 : enable kbf.1 bit in kbf register to generate an interrupt request. kbe.0: keyboard line 0 enable bit 0 : enable standard i/o pin. 1 : enable kbf.0 bit in kbf register to generate an interrupt request.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 71 - mnemonic : kbf address : 95h 7 6 5 4 3 2 1 0 reset - - - - kbf.3 kbf.2 kbf.1 kbf.0 00h kbf.3: keyboard line 3 flag this is set by hardware when kbi3 detects a programmed level. it generates a keyboard interrupt re quest if kbe.3 is also set. it must be cleared by software. kbf.2: keyboard line 2 flag this is set by hardware when kbi2 detects a programmed level. it generates a keyboard interrupt request if kbe.2 is also set. it must be cleared by software. kbf. 1: keyboard line 1 flag this is set by hardware when kbi1 detects a programmed level. it generates a keyboard interrupt request if kbe.1 is also set. it must be cleared by software. kbf.0: keyboard line 0 flag this is set by hardware when kbi0 detects a programmed level. it generates a keyboard interrupt request if kbe.0 is also set. it must be cleared by software. mnemonic : kbd address : 96h 7 6 5 4 3 2 1 0 reset kbden - - - - - kbd.1 kbd.0 00h kbden: enable kbi de - bounce function. the default kbi function is enabled. kbden = 0, enable kbi de - bounce function. the de - bounce time is selected by kbd [1:0]. kbden = 1, disable kbi de - bounce function. the kbi input pin without de - bounce mechanism. kbd[1:0]: select kbi de - bounce time. if kbden = ?0?, the default de - bounce time is 320 ms. kbd[1:0] = 00, the de - bounce time is 320 ms. kbd[1:0] = 01, the de - bounce time is 160 ms. kbd[1:0] = 10, the de - bounce time is 80 ms. kbd[1:0] = 11, the de - bounce time is 40 ms.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 72 - 16. lvi & lvr ? low voltage interrupt and low voltage reset the interrupt vector 63h. mnemoni c description addre ss bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst lvi function rsts reset status register a1h - - - pdr f wdtf swrf lvrf porf 00h lvc low voltage control e6h lvi_ en - lvre lv if - - lvis[1:0] 20h mnemonic : rsts address : a1h 7 6 5 4 3 2 1 0 reset - - - pdrf wdtf swrf lvrf porf 00h pdrf: pad reset flag. when mcu is reset by reset pad, pdrf flag will be set to one by hardware. this flag clear by software. lvrf: low voltage reset flag. when mcu is reset by lvr, lvrf flag will be set to one by hardware. this flag clear by software. porf: power on reset flag. when mcu is reset by por, porf flag will be set to one by hardware. this flag clear by software. mnemonic : lvc addres s : e6h 7 6 5 4 3 2 1 0 reset lvi_en - lvre lvif - - lvis[1:0] 20h lvi_en: low voltage interrupt function enable bit. lvi_en = 0 - disable low voltage detect function. lvi_en = 1 - enable low voltage detect function. lvre: external low voltage reset fu nction enable bit. lvre = 0 - disable external low voltage reset function. lvre = 1 - enable external low voltage reset function. lvif: low voltage interrupt flag lvis lvi level select: 00: 1. 7 v 01: 2.6v 10: 3.2v 11: 4.0v
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 73 - 17. 10- bit analog - to - digital co nverter (adc) the sm39 r16a3 provides seven channels 10 - bit adc and one channel adc0 connect to internal vref of 1.2 v 10% ) . ). the digital output data [9:0] were put into adcd [9:0]. the adc interrupt vector is 53h. mux high speed 10 bits adc module adcc 1 [ 7 : 0 ] avss avdd adc 0 adc 7 ? adc 6 adc clock divider ? adcch [ 2 : 0 ] adccs [ 4 : 0 ] fosc start vdd vss ? ? vref 1 . 2 v 10 % adcd [ 9 : 0 ] adc _ isr fig. 17 - 1 : adc operation setting of the analog - to - digital converter the adc sfr show as below: mnemoni c description addr ess bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst adc adcc1 adc control register 1 abh adc7 en adc6 en adc5 en adc4 en adc3 en adc2 en adc1 en adc0 en 00h adcc2 adc control register 2 ach start adju st - - - adcch[2:0] 00h adcdh adc data high byte adh adcdh [7:0] 00h adcdl adc data low byte aeh adcdl [7:0] 00h adccs adc clock select afh - - - adccs[4 :0] 00h mnemonic : adcc1 address : abh 7 6 5 4 3 2 1 0 reset adc7en adc6en adc5en adc4en adc3en adc2en adc1en adc0en 00h adc7en: adc channels 7 enable. adc7en = 1 ? enable adc channel 7 adc6en: adc channels 6 enable.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 74 - adc6en = 1 ? enable adc channel 6 adc5en: adc channels 5 enable. adc5en = 1 ? enable adc channel 5 adc4en: adc channels 4 enable. adc4en = 1 ? enable adc channel 4 adc3en: adc channels 3 enable. adc3en = 1 ? enable adc channel 3 adc2en: adc channels 2 enable. adc2en = 1 ? enable adc ch annel 2 adc1en: adc channels 1 enable. adc1en = 1 ? enable adc channel 1 adc0en: adc channels 0 enable. adc0en = 1 ? enable adc channel 0 (connect to internal verf o f 1.2v 10 %) mnemonic : adcc2 address : ach 7 6 5 4 3 2 1 0 reset start adjust - - - adc ch[2:0] 00h start: when this bit is set, the adc will be start conversion continuous. adjust: adjust the format of adc conversion data. adjust = 0: (default value) adc data high byte adcd [9:2] = adcdh [7:0]. adc data low byte adcd [ 1:0] = adcdl [1:0]. adjust = 1: adc data high byte adcd [9:8] = adcdh [1:0]. adc data low byte adcd [7:0] = adcdl [7:0]. adcch[2:0]: adc channel select. adcch [2:0] channel 000 0 001 1 010 2 011 3 100 4 101 5 110 6 111 7
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 75 - adjust = 0: mnemonic : adcdh address : adh 7 6 5 4 3 2 1 0 reset adcd[9] adcd[8] adcd[7] adcd[6] adcd[5] adcd[4] adcd[3] adcd[2] 00h mnemonic : adcdl address : aeh 7 6 5 4 3 2 1 0 reset - - - - - - adcd[1] adcd[0] 00h adjust = 1: mnemonic : adcdh ad dress : adh 7 6 5 4 3 2 1 0 reset - - - - - - adcd[9] adcd[8] 00h mnemonic : adcdl address : aeh 7 6 5 4 3 2 1 0 reset adcd[7] adcd[6] adcd[5] adcd[4] adcd[3] adcd[2] adcd[1] adcd[0] 00h adcd[9:0]: adc data register. mnemonic : adccs address : afh 7 6 5 4 3 2 1 0 reset - - - adccs[4] adccs[3] adccs[2] adccs[1] adccs[0] 00h adccs[4:0]: adc clock select. *the adc clock maximum 12.5mhz. * the adc conversion rate maximum 961 khz. adccs[4:0] adc clock(hz) clocks for adc conversion 00000 fosc /2 26 000 01 fosc/4 52 00010 fosc /6 78 00011 fosc /8 104 00100 fosc /10 130 00101 fosc /12 156 00110 fosc /14 182 00111 fosc /16 208 01000 fosc /18 234 01001 fosc /20 260 01010 fosc /22 286 01011 fosc /24 312 01100 fosc /26 338 01101 fosc /28 364 01110 fosc /30 390 01111 fosc /32 416 10000 fosc /34 442 10001 fosc /36 468
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 76 - 10010 fosc /38 494 10011 fosc /40 520 10100 fosc /42 546 10101 fosc /44 572 10110 fosc /46 598 10111 fosc /48 624 11000 fosc /50 650 11001 fosc /52 676 11010 fosc /54 702 1 1011 fosc /56 728 11100 fosc /58 754 11101 fosc /60 780 11110 fosc /62 806 11111 fosc /64 832 ) 1 ( 2 fosc _ + = adccs clock adc 13 adc_clock _ _ = rate conversion adc
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 77 - 18. in - system programming (internal isp) the sm39 r16a3 can generate flash control signal by internal hardwar e circuit. users utilize flash control register, flash address register and flash data register to perform the isp function without removing the sm39 r16a3 from the system. the sm39 r16a3 provides internal flash control signals which can do flash program/chi p erase/page erase/protect functions. user need to design and use any kind of interface which sm39 r16a3 can input data. user then utilize isp service program to perform the flash program/chip erase/page erase/protect functions. 18.1 isp service program the isp service program is a user developed firmware program which resides in the isp service program space. after user developed the isp service program, user then determine the size of the isp service program. user need to program the isp service program in the sm39 r16a3 for the isp purpose. the isp service programs were developed by user so that it should includes any features which relates to the flash memory programming function as well as communication protocol between sm39 r16a3 and host device which output data to the sm39 r16a3 . for example, if user utilize uart interface to receive/transmit data between sm39 r16a3 and host device, the isp service program should include baud rate, checksum or parity check or any error - checking mechanism to avoid data transmis sion error. the isp service program can be initiated under sm39 r16a3 active or idle mode. it can not be initiated under power down mode. 18.2 lock bit (n) the lock bit n has two functions: one is for service program size configuration and the other is to lock the isp service program space from flash erase function. the isp service program space address range $3c00 to $3fff. it can be divided as blocks of n*128 byte. (n=0 to 8). when n=0 means no isp function, all of 16kb flash memory can be used as program memo ry. when n=1 means isp service program occupies 128 byte while the rest of 15.875k byte flash memory can be used as program memory. the maximum isp service program allowed is 1k byte when n= 8 . under such configuration, the usable program memory space is 15 k byte. after n determined, sm39 r16a3 will reserve the isp service program space downward from the top of the program address $3fff. the start address of the isp service program located at $3x00 while x is depending on the lo ck bit n. please see table 18 - 1 . program memory diagram for this isp service program space structure. the lock bit n function is different from the flash protect function. the flash erase function can erase all of the flash memory except for the locked isp serv ice program space. if the flash not has been protected, the content of isp service program still can be read. if the flash has been protected, the overall content of flash program memory space including isp service program space can not be read. table 18- 1 : isp code area. n isp service program address 0 no isp service program 1 128 bytes ($3f80h ~ $3fffh) 2 256 bytes ($3f00h ~ $3fffh) 3 384 bytes ($3e80h ~ $3fffh) 4 512 bytes ($3e00h ~ $3fffh) 5 640 k by tes ($3d80h ~ $3fffh) 6 768 k bytes ($3d00h ~ $3fffh) 7 896 k bytes ($3c80h ~ $3fffh) 8 1.0 k bytes ($3c00h ~ $3fffh) isp service program configurable in n* 128 byte (n= 0 ~ 8)
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 78 - 18.3 program the isp service program after lock bit n is set and isp service pro gram been programmed, the isp service program memory will be protected (locked) automatically. the lock bit n has its own program/erase timing. it is different from the flash memory program/erase timing so the locked isp service program can not be erased b y flash erase function. if user needs to erase the locked isp service program, he can do it by writer only. user can not change isp service program when sm39 r16a3 was in system. 18.4 initiate isp service program to initiate the isp service program is to load t he program counter (pc) with start address of isp service program and execute it. there are four ways to do so: (1) blank reset. hardware reset with first flash address blank ($0000=#ffh) will load the pc with start address of isp service program. the hardwar e reset includes max810 (power on reset) and external pad reset. the hardware will issue a strobe window about 256us after hardware reset. (2) execute jump instruction can load the start address of the isp service program to pc. (3) enter?s isp service program b y hardware setting. user can force sm39 r16a3 enter isp service program by setting p1.6 ? active low? during hardware reset period. the hardware reset includes max810 (power on reset) and external pad reset. the hardware will issue after hardware reset. in application system design, user should take care of the setting of p1.6 at reset period to prevent sm39 r16a3 from entering isp service program. (4) enter?s isp service program by hardware setting, the p1.1(rxd) will be detected the two clock signals during ha rdware reset period. the hardware reset includes max810 (power on reset) and external pad reset. the hardware will issue to detect 2 clock signals after hardware reset. during the strobe window, the hardware will detect the status of p1.6/p1.1. if they mee t one of above conditions, chip will switch to isp mode automatically. after isp service program executed, user need to reset the sm39 r16a3 , either by hardware reset or by wdt, or jump to the address $0000 to re - start the firmware program. there are 8 kind s of entry mechanisms for user different applications. this entry method will select on the writer or isp. (1) first address blank. i.e. $0000 = 0xff. and triggered by internal reset signal. (2) first address blank. i.e. $0000 = 0xff. and triggered by pad reset s ignal. (3) p1.6 = 0. and triggered by internal reset signal. (4) p1.6 = 0. an d triggered by pad reset signal . (5) p1.1 input 2 clocks. and triggered by internal reset signal. (6) p1.1 input 2 clocks. and triggered by pad reset signal.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 79 - 18.5 isp register ? takey, ifcon, ispfah , ispfal, ispfd and ispfc mnemonic description dir. bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 rst isp function takey time access key register f7h takey [7:0] 00h ifcon interface control register 8fh - cdpr - - - - - ispe 00h ispfah isp flash address ? high register e1h - - ispfah [5:0] ffh ispfal isp flash address ? low register e2h ispfal [7:0] ffh ispfd isp flash data register e3h ispfd [7:0] ffh ispfc isp flash control register e4h emf1 - emf3 emf4 - ispf.2 ispf.1 ispf.0 00h mnem onic : takey address : f7h 7 6 5 4 3 2 1 0 reset takey [7:0] 00h isp enable bit (ispe) is read - only by default, software must write three specific values 55h, aah and 5ah sequentially to the takey register to enable the ispe bit write attribute. that is: mov takey, #55h mov takey, #0aah mov takey, #5ah mnemonic : ifcon address : 8fh 7 6 5 4 3 2 1 0 reset - cdpr - - - - - ispe 00h the bit 0 (ispe) of ifcon is isp enable bit. user can enable overall sm39 r16a3 isp function by setting ispe bit to 1, to di sable overall isp function by set ispe to 0. the function of ispe behaves like a security key. user can disable overall isp function to prevent software program be erased accidentally. isp registers ispfah, ispfal, ispfd and ispfc are read - only by default. software must be set ispe bit to 1 to enable these 4 registers write attribute. mnemonic : ispfah address : e1h 7 6 5 4 3 2 1 0 reset - - ispfah5 ispfah4 ispfah3 ispfah2 ispfah1 ispfah0 ffh ispfah [5:0]: flash address - high for isp function mnemonic : ispfal address : e2h 7 6 5 4 3 2 1 0 reset ispfal7 ispfal6 ispfal5 ispfal4 ispfal3 ispfal2 ispfal1 ispfal0 ffh ispfal [7:0]: flash address - low for isp function
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 80 - the ispfah & ispfal provide the 14 - bit flash memory address for isp function. the flash mem ory address should not include the isp service program space address. if the flash memory address indicated by ispfah & ispfal registers overlay with the isp service program space address, the flash program/page erase of isp function executed thereafter wi ll have no effect. mnemonic : ispfd address : e3h 7 6 5 4 3 2 1 0 reset ispfd7 ispfd6 ispfd5 ispfd4 ispfd3 ispfd2 ispfd1 ispfd0 ffh ispfd [7:0]: flash data for isp function . the ispfd provide the 8 - bit data register for isp function. mnemonic : ispfc address : e4h 7 6 5 4 3 2 1 0 reset emf1 - emf3 emf4 - ispf[2] ispf[1] ispf[0] 00h emf1: entry mechanism (1) flag, clear by reset. (read only) emf3: entry mechanism (3) flag, clear by reset. (read only) emf4: entry mechanism (4) flag, clear by reset. (read only) ispf [2:0]: isp function select bit. ispf[2:0] isp function 000 byte program 001 chip protect 010 page erase 011 chip erase 100 write option 101 read option 110 erase option 111 reserved one page of flash memory is 128byte the optio n function can access the xtal1 and xtal2 swap to i/o pins select(description in section 1.2) internal reset time select(description in section 1.4.1) clock source select(description in section 1.5) reset swap to i/o pins function select(description in sec tion 5) wdten control bit(description in section 9) or isp entry mechanisms select(description in section 18). when chip protected or no isp service, option can only read. the choice isp function will start to execute once the software write data to ispf c register . to perform byte program/page erases isp function, user need to specify flash address at first. when performing page erase function, sm39 r16a3 will erase entire page which flash address indicated by ispfah & ispfal registers located within the p age. e.g. flash address: $ xymn page erase function will erase from $xy00 to $xyff to perform the chip erase isp function, sm39 r16a3 will erase all the flash program memory except the isp service program space. to perform chip protect isp function, the sm3 9 r16a3 flash memory content will be read #00h.
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 81 - e.g. isp service program to do the byte program - to program #22h to the address $1005h mov takey, #55h mov takey, #0aah mov takey, #5ah ; enable ispe write attribute orl ifcon, #01h ; enable sm39r 1 6 a3 isp function mov ispfah, #10h ; set flash address - high, 10h mov ispfal, #05h ; set flash address - low, 05h mov ispfd, #22h ; set flash data to be programmed, data = 22h mov ispfc, #00h ; start to program #22h to the flash address $1005h mov takey, #55h mov takey, #0aah mov takey, #5ah ; enable ispe write attribute anl ifcon, #0feh ; disable sm39r 16 a3 isp function
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 82 - 19. comparator sm39 r16a3 had integrated two comparator module on chip. this module supports comparator modes individu ally according to user?s configuration. when comparator mode enabled, an internal reference voltage is available to be configured on comparator terminals. comparator sfrs as follows : mnemoni c description addr bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bi t 0 rst comparator oppin opcmp pin select f6h - cmp0 _en c0posvb g c0posp ad - cmp1_ en c1posv bg c1posp ad 00h cmp0co n comparator_ 0 control feh hys0e n cmp0 o cmf0ms[1:0] cmf0 cmp0 outen - - 00h cmp1co n comparator_ 1 control ffh hys1e n cmp1 o cmf1ms[1:0] c mf1 cmp1 outen - - 00h mnemonic : oppin address : f6h 7 6 5 4 3 2 1 0 reset - cmp0_e n c0posvb g c0posp ad - cmp1_ en c1posvb g c1posp ad 00h cmp0_en : cmp0 enable. 1: comparator_0 circuit enables and switch to corresponding signal in multi - function pin p0 .3/p0.4/p0.6 by hw automatically. c0posvbg : select comparator_0 positive input source 1: set positive input source as internal reference voltage (1.2 v10%) c0pospad: select comparator_0 positive input source 1: set positive input source as external pi n cmp1_en : cmp1 enable. 1: comparator_1 circuit enables and switch to corresponding signal in multi - function pin p0.0/p0.1/p0.2 by hw automatically. c1posvbg: select comparator_1 positive input source 1: set positive input source as internal reference v oltage (1.2 v10%) c1pospad: select comparator_1 positive input source 1: set positive input source as external pin
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 83 - cmpx out cmpx_en cxposvbg cxpospad setting table cmpx_en cxposvbg cxpospad cmpxout_en comparator cmpxpin cmpxnin cmpxout 0 x x x io io io 1 0 1 0 io cmp io 1 0 1 1 io io cmp 1 1 0 0 cmp cmp io 1 1 0 1 cmp cmp cmp mnemonic : cmp0con address :feh 7 6 5 4 3 2 1 0 reset hys0en cmp0o cmf0ms[1:0] cmf0 cmp0 outen - - 00h hys0en: hysteresis function enable 0: disable hyste resis at comparator_0 input 1: enable cmp0o: comparator_0 output (read only) 0: the positive input source was lower than negative input source 1: the positive input source was higher than negative input source cmf0ms[1:0] : cmf0(comparator_0 flag) sett ing mode select 00: cmf0 will be set when comprator_0 output toggle 01: cmf0 will be set when comprator_0 output rising 10: cmf0 will be set when comprator_0 output falling 11: reserved cmf0: comparator_0 flag this bit is setting by hardware according to meet cmf0ms [1:0] select condition. this bit must clear by software. cmp0outen: comparator0 output enable 0: comparator0 will not output to external pin 1: comparator0 will output to external pin mnemonic : cmp1con address :ffh 7 6 5 4 3 2 1 0 reset hys1en cmp1o cmf1ms[1:0] cmf1 cmp1 outen - - 00h hys1en: hysteresis function enable 0: disable hysteresis at comparator_1 input 1: enable cmp1o: comparator_1 output (read only) 0: the positive input source was lower than negative input source 1: the positive input source was higher than negative input source
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 84 - cmf1ms[1:0] : cmf1(comparator_1 flag) setting mode select 00: cmf1 will be set when comprator_1 output toggle 01: cmf1 will be set when comprator_1 output rising 10: cmf1 will be set when compra tor_1 output falling 11: reserved cmf1: comparator_1 flag this bit is setting by hardware according to meet cmf1ms [1:0] select condition. this bit must clear by software. cmp1outen: comparator1 output enable 0: comparator0 will not output to external p in 1: comparator0 will output to external pin
SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 85 - operating conditions symbol description min. typ. max. unit. remarks ta operating temperature - 40 25 85 ambient temperature under bias vdd supply voltage 1. 8 5.5 v vref internal reference voltage 1.1 1.2 1. 3 v dc characteristics t a = - 40 to 85 , v cc = 5.0v symbol parameter valid min tpy max units conditions vil1 input low - voltage port 0,1,3 - 0. 5 0.8 v vcc=5v vil2 input low - voltage res, xtal1 0 0.8 v vih1 input high - voltage port 0,1,3 2.0 vcc + 0.5 v vih2 input high - voltage res, xtal1 70%vcc vcc + 0.5 v vol output low - voltage port 0,1,3 0.45 v iol= 16 ma vcc=5v p0.5/p0.7/p1.2/p1.5/ p1.6/p1.7/p3.0/p3.1 0.45 v iol= 39 ma vcc=5v voh1 output high - voltage using strong pull - up (1) port 0,1,3 90% vcc v ioh= - 8 ma p0.5/p0.7/p1.2/p1.5/ p1.6/p1.7/p3.0/p3.1 90% vcc v ioh= - 16ma voh2 output high - voltage using weak pull - up (2) port 0,1 ,3 2.4 v ioh= - 250ua iil logic 0 input current port 0,1,3 - 75 ua vin= 0.45v itl logical transition current port 0,1,3 - 650 ua vin= 2.0v ili input leakage current port 0,1,3 10 ua 0.45v SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 86 - ta = - 40 to 85 , vcc = 3.0v symbol parameter valid min tpy max units conditions vil1 input low - voltage port 0,1,3 - 0.5 0.8 v vcc=3.0v vil2 input low - voltage res, xtal1 0 0. 8 v vih1 input high - voltage port 0,1,3 2.0 vcc + 0.5 v vih2 input high - voltage res, xtal1 70%vcc vcc + 0.5 v vol output low - voltage port 0,1,3 0.45 v iol= 15 ma vcc=3.0v p0.5/p0.7/p1.2/p1.5/ p1.6/p1.7/p3.0/p3.1 0.45 v iol= 25 ma vcc=3.0v voh1 output high - voltage using strong pull - up (1) port 0,1,3 90% vcc v ioh= - 5.5 ma p1.6/p1.7/p3.0/p3.1 90% vcc ioh= - 11ma voh2 output high - voltage using weak pull - up (2) port 0,1,3 2.4 v ioh= - 77ua iil logic 0 input current port 0,1,3 - 75 ua vin= 0.45v itl logical transition current port 0,1,3 - 650 ua vin=1.5v ili input leakage current port 0,1,3 10 ua 0.45v SM39R16A3 8 - bit micro - controller with 16 kb isp flash & 512b ram embedded specifications subject to change without notice contact your sales representatives f or the most recent information . i ssfd - m 065 ver f SM39R16A3 06/ 30 /2015 - 87 - adc characteristics symbol test conditi on min typ max unit operation v dd v dd 2.7 5.5 v resolution 10 bit conversion time 13t adc us sample rate 870k hz integral non - linearity error inl - 1 1 lsb differential non - linearity dnl - 1 1 lsb clock frequency adcclk 11.36 - 5.25 m hz comparator characteristics ta=25 symbol description test condition min tpy max unit v dd condition i op operating current 5 - - 10 10 ua - power down current 5 - - - 0.1 ua - offset voltage 5 - - 10 - +10 mv v cm input voltage commom mode ra nge - - vss - v dd - 1.5 v tp propagation delay 5 vin=10mv - 3 6 us lvi& lvr characteristics lvr min typical max 1.8v ~ 5.5v vil=1.4v vil=1.5v vil=1. 6 v lvi min typical max lvis[1:0] = 00 vil=1. 6 v vil=1. 7 v vil=1. 8 v lvis[1:0] = 01 vil=2. 5 v vi l=2.6v vil=2.7v lvis[1:0] = 10 vil=3. 1 v vil=3.2v vil=3.3v lvis[1:0] = 11 vil=3. 9 v vil=4.0v vil=4. 1 v notes : the v lvi always above v lvr about 0.2v


▲Up To Search▲   

 
Price & Availability of SM39R16A3

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X